Notes on switching backends to qt4 on mac os x

Here are some notes I made -- I hope it might save someone a bit of time.

So, I finally tried out a few other backends on mac os x. I had been recommending and using TkAgg, as this works out of the box on mac os x. However, it seems unsnappy sometimes, and there was this strange issue with the first window not giving control back to the command line.

QT4 takes *forever* to compile, but it seems to compile easier now than previous versions that needed a small library hack. The default configuration compiles and installs fine. The other tools (PyQt4 and SIP) also compile and install painlessly with the default configuration.

I initially forgot to set the -q4thread for ipython (since the other -pylab flag is hidden in a launching script). After that it worked mostly fine.

I found that the correct threading was sensitive to how I started ipython. I have been using terminal, and I was starting ipython like this:

bash -l -c /path/to/ipython -q4thread

from within a terminal .term file (i.e., the terminal starts running ipython automatically). This seems to not work great. However, when I put this command in a script, and run the script like

bash -l -c pylab_start_script

thinks work as expected. This is also true when just typing these commands in on the command line. I almost always start ipython from a terminal .term file from quicksilver. This gives me a dedicated (color coded) ipython window instantly that does not take away my shell. This is all pretty slick, and I am pleased with the setup now.

Developers: Finally, I had to make some small changes to the qt4 backend so that things worked right. One is an essential change -- the latin1() method no longer exists in the newer qt. The other is a cosmetic change so that I can see the cursor position in the toolbar better. Diff below.

-Rob

Index: backend_qt4.py

···

===================================================================
--- backend_qt4.py (revision 2999)
+++ backend_qt4.py (working copy)
@@ -148,7 +148,7 @@
      def _get_key( self, event ):
          if event.key() < 256:
- key = event.text().latin1()
+ key = str(event.text())
          elif self.keyvald.has_key( event.key() ):
              key = self.keyvald[ event.key() ]
          else:
@@ -290,7 +290,7 @@
              # The automatic layout doesn't look that good - it's too close
              # to the images so add a margin around it.
- margin = 4
+ margin = 12
              button.setFixedSize( image.width()+margin, image.height()+margin )
              QtCore.QObject.connect( button, QtCore.SIGNAL( 'clicked()' ),
@@ -301,7 +301,7 @@
          # The stretch factor is 1 which means any resizing of the toolbar
          # will resize this label instead of the buttons.
          self.locLabel = QtGui.QLabel( "", self )
- self.locLabel.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter )
+ self.locLabel.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTop )
          self.locLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored,
                                                        QtGui.QSizePolicy.Ignored))
          self.layout.addWidget( self.locLabel, 1 )

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

Hi Rob,

Developers: Finally, I had to make some small changes to the qt4
backend so that things worked right. One is an essential change --
the latin1() method no longer exists in the newer qt. The other is a
cosmetic change so that I can see the cursor position in the toolbar
better. Diff below.

Thanks for the notes, and for the patch. I moved the margin adjustment you
suggested into a class attribute of NavigationToolbar2QT. This way,
FigureManagerQT can get that information, which is needed to properly set the
height of the figure window. (figsize=(6,4) should yield a 6"x4" plotting
area, the height of the entire window is larger than 4" to accommodate the
toolbar.) Changes in svn 3004.

Darren

···

On Wednesday 07 February 2007 09:06:42 am Rob Hetland wrote: