emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.95k stars 1.58k forks source link

DataFrame (Polars) support #2319

Closed frankvgompel closed 2 months ago

frankvgompel commented 1 year ago

https://github.com/emilk/egui/discussions/2222

Is this possible? I am actually rebuilding a project I did in Python with Streamlit. Gives great possibilities for data dashboards. Perhaps worth looking into.

coderedart commented 1 year ago

you need to format the data yourself. egui already has examples in demo for table/grid, polars dataframe implements iterators / indexing etc.. and you can use it as the source data for table / grid widgets. look at https://egui.rs for the table demo and it will also have a source link at the bottom of the demo widget. image

this is not a feature request btw. just a question.

frankvgompel commented 1 year ago

this is not a feature request btw. just a question.

Well, I asked if it was possible to support so you might consider my question elevated into a feature request. Anyway thanks, I have already been working on a general dataframe table but new to Rust and struggling (also with Polars btw).

frankvgompel commented 1 year ago

But since you say I have to format the data myself, could you at least give some info why the console is able to pretty-print a polars dataframe but it seems egui isn't?

coderedart commented 1 year ago

But since you say I have to format the data myself, could you at least give some info why the console is able to pretty-print a polars dataframe but it seems egui isn't?

These kinds of questions are better answered in discord. Both egui and plars got their own discord servers where you can get help.

Anyway, this could be an issue with fonts. First, terminal fonts are monospace, so the columns always align. I think ui label doesn't do that. Second, polars could be printing different strings in egui vs terminals based on the env as seen here https://pola-rs.github.io/polars/src/polars_core/fmt.rs.html#353 . In particular, the chars used for egui dont seem like ... or === which seem to be used for console. Because egui already supports those chars.

I am on mobile, so hard to test atm.

emilk commented 2 months ago

An integration between Polars and Table is best left to a 3rd party crate