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

silx.gui: Added support for QT_API environment variable #3981

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

t20100
Copy link
Member

@t20100 t20100 commented Nov 28, 2023

This PR adds support for selecting the Qt binding with QT_API env. var. (case-insensitive) the same way as matplotlib and close to qtpy - which is case sensitive.

@t20100 t20100 requested a review from mretegan November 28, 2023 15:23
Copy link
Member

@vasole vasole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If silx choses the binding, QtPy and matplotlib should be informed to prevent warnings.

(Sorry, I did not manage to propose the changes and I committed directly)

@t20100
Copy link
Member Author

t20100 commented Nov 29, 2023

There is no need to set/change the environment variable, both qtpy and matplotlib first check for already imported bindings, so I would prefer not to change the env. var. If it is fine for you, I would revert your change.

If one of the APIs has already been imported, then it will be used.

Otherwise, the shim will automatically select the first available API (PyQt5, PySide2,
PyQt6 and PySide6); in that case, you can force the use of one
specific bindings (e.g. if your application is using one specific bindings and
you need to use library that use QtPy) by setting up the ``QT_API`` environment
variable.
At runtime, these backends select the actual binding used as follows:

    If a binding's QtCore subpackage is already imported, that binding is selected (the order for the check is PyQt6, PySide6, PyQt5, PySide2).

    If the [QT_API](https://matplotlib.org/stable/users/installing/environment_variables_faq.html#envvar-QT_API) environment variable is set to one of "PyQt6", "PySide6", "PyQt5", "PySide2" (case-insensitive), that binding is selected. (See also the documentation on [Environment variables](https://matplotlib.org/stable/users/installing/environment_variables_faq.html#environment-variables).)

    Otherwise, the first available backend in the order PyQt6, PySide6, PyQt5, PySide2 is selected.

@vasole
Copy link
Member

vasole commented Nov 29, 2023

There is no need to set/change the environment variable, both qtpy and matplotlib first check for already imported bindings, so I > would prefer not to change the env. var. If it is fine for you, I would revert your change.

There is no need, but I was so annoyed of seeing the warning "selected binding pyqt5 could not be found, using pyside6" that I did not realize the warning seems to have been removed in recent versions.

image

You can revert my commit if you wish.

@t20100
Copy link
Member Author

t20100 commented Nov 29, 2023

You can revert my commit if you wish.

Done

@mretegan
Copy link
Member

Thank you @t20100! I tested it and it works as expected.

@mretegan mretegan merged commit e667e70 into silx-kit:main Nov 29, 2023
7 checks passed
@t20100 t20100 deleted the qt_api branch December 4, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants