adamerose / PandasGUI

A GUI for Pandas DataFrames
MIT No Attribution
3.19k stars 233 forks source link

Automatic script when a file is dragged&droped #194

Open brianjoubert opened 2 years ago

brianjoubert commented 2 years ago

Hi,

I was wondering if it would be possible to run a short python script each time a file is dragged and dropped. Basically now I am loading a json file as a dataframe in a jupyter notebook, applying some filtering and conversion and then I open PandasGUI with this dataframe. This works very well but I wanted to know if I could include this small script somewhere to do it automatically when someone does drag and drop a file in PandasGUI?

Thanks again for this really nice project!

adamerose commented 2 years ago

I plan to add support for plugins eventually which would make this kind of thing easier, for this case maybe the plugin API would include the ability to connect functions to event listeners and file load would be one possible event.

But as of now, this use case is too niche for me to add to the main project - I think you could probably do this yourself though via subclassing. Take a look at gui.py (pandasgui.gui) specifically the dropEvent method. You have two options....

brianjoubert commented 2 years ago

Thanks a lot,

I will give it a try. The plugin idea is actually definitely a good idea also