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

No side effects #224

Open
mottosso opened this issue Jul 27, 2017 · 0 comments
Open

No side effects #224

mottosso opened this issue Jul 27, 2017 · 0 comments
Labels

Comments

@mottosso
Copy link
Owner

In response to an issue appearing on a project similar to Qt.py called "qtpy" I figure it'd be a good time to highlight an important difference between the two.

No side-effects

The problem is this - with qtpy, existing members of the original binding are modified on import.

Example

from PySide2.QtWidgets import QHeaderView

_setResizeMode = QHeaderView.setResizeMode
def setSectionResizeMode(self, *args):
    _setResizeMode(self, *args)

QHeaderView.setSectionResizeMode = setSectionResizeMode

Problem

For the qtpy parent project "Spyder" this is no problem as it is the only running application within a single Python interpreter. But for those using Qt.py in an interpreter where it is used alongside tens or hundreds of applications running in parallel this can be catastrophic as it means altering the assumptions upon which the applications were built.

It could cause trouble not just for the tools of your peers, but for the application itself - such as Maya and Houdini - that build their own internal tools using the provided original binding, ranging from crashes to difficult-to-debug issues that "works on my machine" (tm).

It's suddenly difficult to impossible to know "is this a problem with Maya, or with one of the GUIs I imported somewhere along the line?"

Solution

In Qt.py, optional wrappers co-exist with their originals.

from Qt import QtCompat
QtCompat.setSectionResizeMode(header, QtWidgets.QHeaderView.Fixed)

Stay safe,
Marcus

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

No branches or pull requests

1 participant