You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importos# Use os.path.pathsep for linux/windows compatibility. Linux uses `:` and windows uses `;`os.environ['QT_PREFERRED_BINDING'] =os.path.pathsep.join(["PyQt5","PySide2"])
importQtimportmy_library.Qt# Both Qt modules use the same bindingassertQt.__binding__=='PyQt5'assertmy_library.Qt.__binding__=='PyQt5'
However if you are wanting to control this for your library and not cause problems if other libraries don't work well with PyQt5 you should use the newer environment variable so that only your Qt.py module attempts to use PyQt5. In this example you have a copy of Qt.py inside my_library.
importosos.environ['QT_PREFERRED_BINDING_JSON'] ="{"my_library.Qt":["PyQt5","PySide2"]}"importQtimportmy_library.Qt# Only my_library.Qt uses the PyQt5 binding, other Qt modules work as normalassertQt.__binding__=='PySide2'assertmy_library.Qt.__binding__=='PyQt5'
I would recommend setting these variables globally for the session, not inside your library. I set QT_PREFERRED_BINDING_JSON as part of a plugin for Maya and startup scripts for 3ds Max, Nuke, etc.
I'm pretty sure I already relied on that in the past but I cannot find anything in the readme about it.
I'm using Qt.py as a dependency in a library that might be used in both PyQt5 and PySide2.
I want to do something like this:
The text was updated successfully, but these errors were encountered: