| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -91,7 +91,7 @@ def paintEvent( self, e ): | |
| else: | ||
| stringBuffer = self.renderer._renderer.tostring_argb() | ||
|
|
||
| qImage = QtGui.QImage(stringBuffer, self.renderer.width, | ||
| qImage = QtGui.QImage(stringBuffer, self.renderer.width, | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWith ubuntu 11.4 (pyside 1.0.1 & qt4 4.7.2), I get a following exception. TypeError: 'PySide.QtGui.QImage' called with wrong argument types: Converting stringBuffer to a buffer object explicitly seem to solve the problem (both pyqt and pyside works), but i'm not sure if this behavior will depend on the pyside version. qImage = QtGui.QImage(buffer(stringBuffer), int(self.renderer.width),
int(self.renderer.height),
We may need a same change at line 117. -JJ
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis is a PySide bug fixed in 1.0.2 http://bugs.pyside.org/show_bug.cgi?id=489
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWe should probably add a version check against PySide then, since we know 1.0.2 is the minimum workable version.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGood to know that this is a pyside bug. However, using explicit buffer call does any harm to matplotib w/ pyside v1.0.2?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes. Wrapping with buffer makes it work in both versions. I was under the impression that mpl wasn't in the business of fixing bugs for specific versions of on specific platforms etc. In any case, there's another bug (819, see my opening comment) that wasn't fixed until 1.0.2 (try saving a figure). There is also an outstanding bug that prevents this backend working on mac (809) that won't be fixed until 1.0.3. I'd suggest that 1.0.3 should probably be the minimum supported version to keep things simple. In which case this can stay as is. Unless there is a good reason to want to wrap with buffer() in any case?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIn my experience, mpl tries to broadly support as many versions of a library on as many platforms as feasible. I don't know if it's stated explicitly anywhere, but at least in my work environment, it is very important to support rather old and possibly buggy versions of core dependencies (e.g. GUI toolkits) for quite some time. Look at the GTK backend, for example, for a number of version-specific hacks that have been required over time. Eventually the idea is to prune that stuff out -- my own rule of thumb is to support at least as far back as whatever was in the (current release - 2) of RHEL. In this specific case, however, with PySide being so new and cutting edge to begin with, I think it's ok to require a minimum version and not add hacks for 1.0.x which were fairly ephemeral and not widely-used releases. But the version check is important because user's should understand it's breaking because of an old version of PySide and not some other reason.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI was inclined to fix the buffer thing since pyside v1.0.1 is packaged for ubuntu, and this simple fix at least makes the backend usable. Anyhow, I agree with Michael and the current approach is okay.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOk, that's good then. As a side note, I was under the impression that Ubuntu was more or less the development platform for PySide. Every version of PySide is packaged for it within a few hours of release isn't it?
Sorry, something went wrong.
All reactions
|
||
| self.renderer.height, | ||
| QtGui.QImage.Format_ARGB32) | ||
| p = QtGui.QPainter(self) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """ A Qt API selector that can be used to switch between PyQt and PySide. | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| # Available APIs. | ||
| QT_API_PYQT = 'pyqt' | ||
| QT_API_PYSIDE = 'pyside' | ||
|
|
||
| # Select PyQt4 or PySide using an environment variable, in the same way IPython does. | ||
| # IPython is using PyQt as default (for now) so we will too. | ||
| QT_API = os.environ.get('QT_API', QT_API_PYQT) | ||
|
|
||
| if QT_API == QT_API_PYQT: | ||
| try: | ||
| from PyQt4 import QtCore, QtGui | ||
| except ImportError: | ||
| raise ImportError("Qt4 backend requires that PyQt4 is installed.") | ||
| # Alias PyQt-specific functions for PySide compatibility. | ||
| try: | ||
| QtCore.Slot = QtCore.pyqtSlot | ||
| except AttributeError: | ||
| QtCore.Slot = pyqtSignature # Not a perfect match but | ||
| # works in simple cases | ||
| QtCore.Property = QtCore.pyqtProperty | ||
| __version__ = QtCore.PYQT_VERSION_STR | ||
| import sip | ||
| try : | ||
| if sip.getapi("QString") > 1 : | ||
| # Use new getSaveFileNameAndFilter() | ||
| _getSaveFileName = lambda self, msg, start, filters, \ | ||
| selectedFilter : \ | ||
| QtGui.QFileDialog.getSaveFileNameAndFilter( \ | ||
| self, msg, start, filters, selectedFilter)[0] | ||
| else : | ||
| # Use old getSaveFileName() | ||
| _getSaveFileName = QtGui.QFileDialog.getSaveFileName | ||
| except (AttributeError, KeyError) : | ||
| # call to getapi() can fail in older versions of sip | ||
| # Use the old getSaveFileName() | ||
| _getSaveFileName = QtGui.QFileDialog.getSaveFileName | ||
|
|
||
| elif QT_API == QT_API_PYSIDE: | ||
| try: | ||
| from PySide import QtCore, QtGui, __version__, __version_info__ | ||
| except ImportError: | ||
| raise ImportError("Qt4 backend requires that PySide is installed.") | ||
| if __version_info__ < (1,0,3): | ||
| raise ImportError("Matplotlib backend_qt4 and backend_qt4agg require PySide >=1.0.3") | ||
|
|
||
| # Alias PySide-specific function for PyQt compatibilty | ||
| QtCore.pyqtProperty = QtCore.Property | ||
| QtCore.pyqtSignature = QtCore.Slot # Not a perfect match but | ||
| # works in simple cases | ||
|
|
||
| _getSaveFileName = lambda self, msg, start, filters, selectedFilter : \ | ||
| QtGui.QFileDialog.getSaveFileName(self, \ | ||
| msg, start, filters, selectedFilter)[0] | ||
| else: | ||
| raise RuntimeError('Invalid Qt API %r, valid values are: %r or %r' % | ||
| (QT_API, QT_API_PYQT, QT_API_PYSIDE)) |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDoes this drop support for PyQt 4.6 and earlier? At my institution, we are still standardized on RHEL5 which comes with PyQt 4.2. We should support at least that far back.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAs best I can tell this only has an impact on early versions of 4.6.x. The fix is certainly only applied to PyQt 4.6.x and the bug was apparently fixed in 4.6.2. Even if you're stuck with 4.6 I would've thought you'd at least have the most recent version of it.
I.e. this will only break support for 4.6.0 and 4.6.1 everything else will remain the same.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGreat. Thanks for the confirmation. I think it's fine to not support obsolete maintenance releases.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.