GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PySide backend support by gstorer · Pull Request #80 · matplotlib/matplotlib

Conversation

@gstorer

@gstorer gstorer commented Apr 11, 2011

Copy link
Copy Markdown
Contributor

Hi,
I've modified the Qt backend to switch between PySide and PyQt using the same environment variable as IPython.

There are a couple of outstanding bugs in PySide that are apparent in matplotlib:
489 - temporary work around in qt.py that can be removed when PySide fixes the bug. Fixed in source.
819 - temporary work around in qt.py that can be removed when PySide fixes the bug. Default file filter isn't set.
736 - Only affects the subplot configuration tool. Fixed in PySide 1.0.1.

I also removed the 'hackish' fix for the bug in early version of PyQt 4.6.x - it could be added to qt.py if it was felt necessary.

I've added a Qt slot to the FigureManagerQT class that passes straight through to the status bar - this seemed to fix a segfault that may or may not be a bug in PySide. I haven't been able to separately reproduce it and PySide isn't really suppose to support the old style slots/signals.

I've modified formlayout to use getColor instead of getRgba as PySide does not have the later function. I also had to alias all of the Qt names used by formlayout as you can't double import things.

Regards,
Gerald.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gstorer added 6 commits April 11, 2011 15:39
@gstorer
Added PySide support to Qt4 backend.
f73a1c9
@gstorer
Merge branch 'master' of https://github.com/matplotlib/matplotlib
fcdc78f
@gstorer
Remove fix for PySide bug 489.
bd8658c
@gstorer
Fix for the removal of old-style class support from PySide.
6844901
@gstorer
Fix for the removal of old-style class support from PySide.
6ccb243
@gstorer
Remove some tabs accidentally added.
89f82f2
@gstorer

gstorer commented Apr 28, 2011

Copy link
Copy Markdown
Contributor Author

Updated to remove the fix for PySide bug 489 and added a work around for the PySide removal of support for old style classes.

The only outstanding bug is 819 where the default file filter can't be set.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gstorer added 2 commits April 28, 2011 14:00
@gstorer
Change attribute check to use hasattr().
ecd7ffd
@gstorer
Remove work around for PySide bug 819. Bug was fixed in PySide 1.0.2
e13997d
@gstorer

gstorer commented May 2, 2011

Copy link
Copy Markdown
Contributor Author

There are now no outstanding bugs with PySide that matplotlib exposes (that I am aware of).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdboom
mdboom reviewed May 6, 2011
View reviewed changes
Comment thread lib/matplotlib/backends/qt.py Outdated

@mdboom mdboom May 6, 2011

Copy link
Copy Markdown
Member

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.

The name of this file is problematic. It breaks the Qt3 backend (since 'qt' is the name of the PyQt library version 3 -- the backend tries to import the bindings but instead gets this file.) It's also confusing to read "from qt import ..." in the Qt4 backends and not have that refer to the main qt library.

Perhaps it should be called "qt4_compat.py" or something similar?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gstorer gstorer May 6, 2011

Copy link
Copy Markdown
Contributor Author

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.

Good point. I just blindly copied the file from IPython but they don't support Qt3.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gstorer added 4 commits May 9, 2011 10:40
@gstorer
Widget, FigureCanvasBase and NavigationToolbar2 changed to new style …
039814b
…classes to support PySide backend.
@gstorer
Qt compatibility library rename and backend_version fix.
aaaec76
@gstorer
Rename qt.py to qt4_compat.py
4e7a8fc
@gstorer
FigureCanvasBase, NavigationToolbar2 and widget changed to new style …
a80b001
…classes.
@gstorer

gstorer commented May 9, 2011

Copy link
Copy Markdown
Contributor Author

All of mdboom's comments implemented. I also changed backend_version while I was at it to be more consistent with the other backends. That is, a version string representing the GUI toolkit's version rather than something arbitrary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

leejjoon
leejjoon reviewed May 9, 2011
View reviewed changes
Comment thread lib/matplotlib/backends/backend_qt4agg.py

@leejjoon leejjoon May 9, 2011

Copy link
Copy Markdown
Contributor

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.

With 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:
PySide.QtGui.QImage(str, int, int, PySide.QtGui.QImage.Format)
Supported signatures:
PySide.QtGui.QImage()
PySide.QtGui.QImage(PySide.QtGui.QImage)
PySide.QtGui.QImage(PySide.QtCore.QSize, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(QString, str = None)
PySide.QtGui.QImage(int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(buffer, int, int, PySide.QtGui.QImage.Format)
PySide.QtGui.QImage(buffer, int, int, int, PySide.QtGui.QImage.Format)

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.
The agg renderer has a "buffer_rgba" method but QImage does not seem to support RGBA format.

-JJ

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gstorer gstorer May 9, 2011

Copy link
Copy Markdown
Contributor Author

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.

This is a PySide bug fixed in 1.0.2 http://bugs.pyside.org/show_bug.cgi?id=489

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mdboom mdboom May 9, 2011

Copy link
Copy Markdown
Member

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.

We should probably add a version check against PySide then, since we know 1.0.2 is the minimum workable version.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@leejjoon leejjoon May 9, 2011

Copy link
Copy Markdown
Contributor

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.

Good to know that this is a pyside bug. However, using explicit buffer call does any harm to matplotib w/ pyside v1.0.2?
I could be wrong but my guess is that if we call buffer explicitly, the code will work for both v1.0.2 and v1.0.1?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gstorer gstorer May 10, 2011

Copy link
Copy Markdown
Contributor Author

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.

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

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mdboom mdboom May 10, 2011

Copy link
Copy Markdown
Member

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.

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

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@leejjoon leejjoon May 11, 2011

Copy link
Copy Markdown
Contributor

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.

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

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gstorer gstorer May 11, 2011

Copy link
Copy Markdown
Contributor Author

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.

Ok, 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gstorer
Added version check for PySide >= 1.0.3.
5c963ae
@gstorer

gstorer commented May 10, 2011

Copy link
Copy Markdown
Contributor Author

I've added a version check for 1.0.3 or greater. The PySide nightly builds are on 1.0.3 (http://www.pyside.org/files/nightly/) although you're limited to Windows or something Debian based.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gstorer

gstorer commented May 27, 2011

Copy link
Copy Markdown
Contributor Author

PySide 1.0.3 has been released. I'll update the dev mailing list to solicit some final testing as packages become available.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gstorer
Updated formlayout to include the float validator
69e8d2d
@ddale

ddale commented Jun 5, 2011

Copy link
Copy Markdown
Contributor

Is this patch ready for final testing? It would be nice to merge in time for the next release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gstorer

gstorer commented Jun 7, 2011

Copy link
Copy Markdown
Contributor Author

Yep. The only thing I'm really waiting on is for someone to tell me there are no show stoppers in OS X. This has been a bit tricky since there isn't a PySide 1.0.3 package for OS X yet. I've asked for it on the PySide mailing list today.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@leejjoon

leejjoon commented Jun 9, 2011

Copy link
Copy Markdown
Contributor

I don't think we have to wait until we have a bug-free PySide. I'm +1 for pulling this immediately. We may update the version check later if necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@leejjoon

leejjoon commented Jun 9, 2011

Copy link
Copy Markdown
Contributor

Running this code from command line raises an exception during the exit. This only happens for "pyside". With "pyqt", it runs okay. This is not a show stopper and this can be fixed after the patch is pulled.

import matplotlib.pyplot as plt
fig= plt.figure(1)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/jjlee/.virtualenvs/mpl-head/lib/python2.6/site-packages/matplotlib/_pylab_helpers.py", line 82, in destroy_all
    manager.destroy()
  File "/home/jjlee/.virtualenvs/mpl-head/lib/python2.6/site-packages/matplotlib/backends/backend_qt4.py", line 373, in destroy
    self._widgetclosed )
RuntimeError: Internal C++ object (PySide.QtGui.QMainWindow) already deleted.
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/jjlee/.virtualenvs/mpl-head/lib/python2.6/site-packages/matplotlib/_pylab_helpers.py", line 82, in destroy_all
    manager.destroy()
  File "/home/jjlee/.virtualenvs/mpl-head/lib/python2.6/site-packages/matplotlib/backends/backend_qt4.py", line 373, in destroy
    self._widgetclosed )
RuntimeError: Internal C++ object (PySide.QtGui.QMainWindow) already deleted.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gstorer

gstorer commented Jun 9, 2011

Copy link
Copy Markdown
Contributor Author

I actually get a error from both pyqt and pyside on exit...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gstorer

gstorer commented Jun 14, 2011

Copy link
Copy Markdown
Contributor Author

I don't know what was going on before but I can't get a runtime error at all now. This might be platform specific. I'm mostly using Windows XP at work. At any rate I think this is good enough to be pulled into master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ddale added a commit that referenced this pull request Jun 16, 2011
@ddale
Merge pull request #80 from gstorer/master
cf0644a
PySide backend support
@ddale
ddale merged commit cf0644a into matplotlib:master Jun 16, 2011
@richbwood richbwood mentioned this pull request Dec 19, 2012
test_pcolormesh hangs #1609
Closed
magnunor pushed a commit to magnunor/matplotlib that referenced this pull request Dec 5, 2013
Francisco de la Peña
Fixes matplotlib#80
efe250d
@QuLogic QuLogic modified the milestones: v1.1.0, v2.0.0 Nov 4, 2015
fariza added a commit to fariza/matplotlib that referenced this pull request Sep 22, 2016
@fariza
Merge pull request matplotlib#80 from fgoudreault/restructure_dataset…
6aa72b9
…_generator

Added the points generator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v1.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@gstorer @ddale @leejjoon @mdboom @QuLogic
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.