It turns out that it was also trivial to get the figure options editor working with PySide.

All that needed to be done was (in formlayout.py):

   * Replace the references to PyQt with PySide
   * Change: from PyQt.QtCore import (Qt, SIGNAL, SLOT, QSize, QString,
                                pyqtSignature, pyqtProperty)
     to: from PySide.QtCore import (Qt, SIGNAL, SLOT, QSize, #QString,
                                #pyqtSignature, pyqtProperty)
                                 Slot as pyqtSignature, Property as
     pyqtProperty)
   * Add the following after the import statements:
     # Hacks to emulate PyQt
     QString = str
     class QColorDialog(QColorDialog):
          @staticmethod
          def getRgba(color,parent):
              result =
     QColorDialog.getColor(QColor.fromRgba(color),parent,'')
              return result.rgba(),result.isValid()

Formlayout could probably be updated so it doesn't need the hacks but I wanted to keep changes to a minimum.

Gerald.

On 17/03/2011 11:21 AM, Gerald Storer wrote:
On 01/18/2011 08:13 PM, Jed Ludlow wrote:
> Please forgive me if I'm raising a heretical question with this since I
> understand the topic of competing Qt bindings for Python gets a little
> touchy in and of itself. Nonetheless, the elephant is in the room. I
> searched the archives and found only a few comments on the subject:
> matplotlib-us...@lists.sourceforge.net/msg18652.html" target="_new">http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg18652.html>
> Has there been any additional discussion among the developers about
> creating a formal backend for Pyside?

Its actually a fairly easy to get the PyQt backend working with PySide. It would have been laughably easy if not for a couple of bugs in PySide that took awhile to track down.

To get it working PySide working you need to:

    * Obviously replace the reference to PyQt with PySide
    * Remove the reference to PyQt/Pyside.Qt and Qt.qApp by replacing
      it with QtGui.qApp (I think this is already done in the most
      recent Git version)
    * Replace the toolbar message signal with a new style signal by:
          o adding 'message = QtCore.Signal(str)' to the
            NavigationToolbar2QT class definition
          o replacing: QtCore.QObject.connect(self.toolbar,
            QtCore.SIGNAL("message"),
self.window.statusBar().showMessage)
            
with:self.toolbar.message.connect(self.window.statusBar().showMessage)
          o replacing: self.emit(QtCore.SIGNAL("message"), s)
            with: self.message.emit(s)
    * Work around the PySide bug with QImage and convert the string
      passed from the Agg backend into a python buffer with
      buffer(stringBuffer) or wait for PySide to fix bug 489.
    * Work around a PySide bug (738) by creating functions to perform
      the slider.setMaxiumum/setMinimum tasks or ignore the runtime
      errors for now and wait for a bug fix.
    * I haven't bothered with the figure options editor at this point
      - I just commented out the references to it.

It might also be a good idea to convert all the signals/slots into the new style but it seems to work just fine with only the above changes.

Regards,
Gerald.
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to