Show Pandas table with RichText

Hello,

I am trying to display a Pandas table on the client side. I have tried to display the table with RichText, but I can’t display all the columns of the dataframe, it cuts…

I attach the image.

This is the code:

Server:

@anvil.server.callable
def pd_tab():
  download_url = ("https://raw.githubusercontent.com/fivethirtyeight/data/master/college-majors/recent-grads.csv")
  df = pd.read_csv(download_url)
  return df.to_markdown()

Client:

self.rich_text_1.content = anvil.server.call('pd_tab')

I would like to use the Pandas style function, or something similar, to get this result:

Any suggestions?

Thanks in advance.

Do you have a clone link, or a stripped down version of this you can turn into a clone link? I think there are easier solutions than setting the scroll bars in markdown.

Yes, this is the simplified clone of the application: Anvil | Login

Here is what I got:

https://anvil.works/build#clone:ZAHW7IZXNIXSQA5J=DKRIEM4KZFS5KG5HIXKKWCFH

I added a role named horizontal_scroll to the RichText box that contains the following css:

.anvil-role-horizontal_scroll {
  max-height: calc(100vh - 9rem);
  overflow-y: scroll;
  overflow-x: scroll;
}

horizontal_scroll_example

3 Likes

It is perfect. Very good solution. Thank you very much!

1 Like

Under Assets → theme.css

Just in case that wasn’t clear to someone reading later, if you have questions look here:

1 Like