Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to qtpy #188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

p-j-smith
Copy link

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:

  • import PyQt5 -> import qtpy
  • from PyQt5 -> from qtpy
  • pyqtSignal -> Signal
  • pyqtSlot -> Slot
  • 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).

A couple of things I'm not sure about:

  • 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?

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

@adamerose
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change the qt calls to use qtpy to deal with different Qt bindings Upgrade to PyQt6
2 participants