adamerose / PandasGUI

A GUI for Pandas DataFrames
MIT No Attribution
3.17k stars 229 forks source link

How to embed into a custom PyQT app? #178

Closed JanC closed 2 years ago

JanC commented 2 years ago

Hi, Is it possible create and use only the DataFrame widget in my own PyQT app?

I'm aware that I can embed the entire PandasUI as explained here using

        gui = show(df)
        self.groupBox.layout().addWidget(gui)

however, I'm interested only in the data frame view. (which I believe is the DataFrameViewer ?)

It's a bit unclear whether PandasGUI is meant to be used as a standalone app or as a library ..

JanC commented 2 years ago

ok by digging into the code, I think the way to achieve this is

from pandasgui.store import PandasGuiDataFrameStore
from pandasgui.widgets.dataframe_viewer import DataFrameViewer

...

pgdf = PandasGuiDataFrameStore(df)
df_view = DataFrameViewer(pgdf)

self.groupBox.layout().addWidget(df_view)

it kind of works, however the view seem to have a fixed size

adamerose commented 2 years ago

@JanC

Yeah you've got the right idea with that snippet.

it kind of works, however the view seem to have a fixed size

Most of my size-related configuration is in DataFrameExplorer, if you're directly using DataFrameViewer you shouldn't have a fixed size. I think the fixed size problem may be related to your own code that isn't shown here? If you try just directly running dataframe_viewer.py (which just creates a DataFrameViewer with some sample data) you should be able to resize it freely with the only minimum sizes being the index width and column header height:

image