Table Prints Hash Code Instead Of Table #1618
-
Hi, I just started using Rich. When I call this function, it just prints def print_bill_items(self) -> None:
table = Table(title="The Bill")
table.add_column("Name", style="magenta")
table.add_column("Price", style="cyan")
table.add_column("Quantity", style="green")
table.add_column("Total", style="red")
for i in range(len(self.ar)):
table.add_row(self.ar[i][0], str(self.ar[i][1]), str(self.ar[i][2]), str(self.ar[i][3]))
print(table) Also this is the function for print (override is a colour) def print(prompt, override: str = None) -> None:
if override is not None:
console.print(f"[{override}]{prompt}[/{override}]")
else:
console.print(f"{prompt}") I'm on Windows 10 and Python 3.9.6. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You're converting the table in to a string in the fstring, which will call You won't be able to style the table by converting it in to a string. But you can set a style on the table, with |
Beta Was this translation helpful? Give feedback.
You're converting the table in to a string in the fstring, which will call
repr
on it. Just foconsole.print(prompt)
.You won't be able to style the table by converting it in to a string. But you can set a style on the table, with
table.style = "red on white"
for example.