adamerose / PandasGUI

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

Switch to qtpy #188

Open p-j-smith opened 2 years ago

p-j-smith commented 2 years ago

FIxes #168 Fixes #116

Hi, thanks for making PandasGui! I plan to use it in an application I'm building with Pyside6 and thought I would help out with the move to using QtPy bindings.

Changes made:

A couple of things I'm not sure about:

I ran the tests locally and they seems to run okay, although there were a few warnings (see test-output.txt

adamerose commented 2 years ago

Removed PyQt5 etc. from requirements.txt and setup.py. Replaced with qtpy. Note, users must ensure they have PyQt/PySide installed (see the qtpy docs). If using PyQt, users must also install PyQtWebEngineWidgets separately (PySide has this built-in).

We should add some logic to handle this automatically, if a user doesn't have any PyQt or PySide version installed (which I think would be most users) it should automatically install some default. I'm open to suggestions on the best way to do that

PandasGui.utility.fix_pyqt - will this fix work for both pyqt and pyside? PandasGui.utility.fix_ipython - if using ipython, sets ipython.magic("gui qt5"). Would ipython.magic("gui qt6") work for PyQt6/PySide6?

Good questions... I can play around with that, I've only tried PyQt5 so far.

p-j-smith commented 2 years ago

Hi, sorry for the really slow reply.

We should add some logic to handle this automatically

That's a fair point. I think the most common way to handle this is with optional dependencies, which can be added in the setup.py:

setup(
    ...,
    extras_require={
        "pyqt5": ["PyQt5", "PyQt5-sip", "PyQtWebEngine"],
        "pyqt6": ["PyQt6", "PyQt6-sip", "PyQtWebEngine"],
        "pyside2": ["PySide2"],
        "pyside6": ["PySide6"],
    },
)

This would still mean that by default none of these dependencies are installed. To install with e.g. pyqt5 a user would need to type:

pip install pandasgui[pyqt5]

But, as far as I know, there is no way to e.g. install pyqt5 by default, and to optionally not install it.

p-j-smith commented 2 years ago

That might not be quite what you're after though. Another option would be to do something similar to what matplotlib does. Matplotlib have created matplotlib-base and matplotlib. matplotlib-base is the entire matplotlib library but does not have qt as a dependency. matplotlib is simply matplotlib-base with an additional dependency of qt. So users who do not need/want qt installed with matplotlb will install matplotlib-base, whilst those who want it install matplotlib. This would mean maintaining two packages for pandas-gui, although one of them will be trivial (pandas-gui would be a simple package that depends on pandas-gui-base and pyqt5 etc.)