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:

The patch works. Thanks. Two more things:

1 - the icons look very small in the toolbar buttons (they look bigger in TkAgg). Is there a fix for this?

2 - the subplot configure toolbar (where you get a pop-up window that lets you modify the axis size and position) does not work. In particular, the sliders do not appear, although everything else seems to work (clicking in the empty window does modify the axis)

These two fixes are beyond my skill set, but I'll help where I can..

-r

···

On Feb 7, 2007, at 8:58 AM, Darren Dale wrote:

Hi Rob,

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

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

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

The patch works. Thanks. Two more things:

1 - the icons look very small in the toolbar buttons (they look
bigger in TkAgg). Is there a fix for this?

I'm not sure. I'll look into it when I get a chance.

2 - the subplot configure toolbar (where you get a pop-up window that
lets you modify the axis size and position) does not work. In
particular, the sliders do not appear, although everything else seems
to work (clicking in the empty window does modify the axis)

This is a known bug. We looked into it a while back, and couldn't make any
headway.

Darren

···

On Wednesday 07 February 2007 10:12:36 am Rob Hetland wrote:

Thanks for doing this Rob, its nice to get as much support on OS-X as possible.

Does the QT back-end need to be compiled against QT? or is it python-only?

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.

Any chance you could package it up an submit it to the pythonmac archive?

Does it support a Universal build?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

The MPL Qt backend requires PyQt (or, better, Qt4 and PyQt4). PyQt does compile against the Qt Library, and also takes quite a while to complete. PyQt does not use setuptools, and I am not sure how to make a generally usable binary distribution from it.

I would say that installation is quite easy (although time consuming) -- perhaps just a good set of directions on the MPL site?

-Rob

···

On Feb 7, 2007, at 10:01 AM, Christopher Barker wrote:

Thanks for doing this Rob, its nice to get as much support on OS-X as
possible.

Does the QT back-end need to be compiled against QT? or is it python-only?

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.

Any chance you could package it up an submit it to the pythonmac archive?

Does it support a Universal build?

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

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

The Qt backend is pure python.

Darren

···

On Wednesday 07 February 2007 12:09:18 pm Rob Hetland wrote:

The MPL Qt backend requires PyQt (or, better, Qt4 and PyQt4). PyQt
does compile against the Qt Library, and also takes quite a while to
complete. PyQt does not use setuptools, and I am not sure how to
make a generally usable binary distribution from it.

I would say that installation is quite easy (although time consuming)
-- perhaps just a good set of directions on the MPL site?

-Rob

On Feb 7, 2007, at 10:01 AM, Christopher Barker wrote:
> Thanks for doing this Rob, its nice to get as much support on OS-X as
> possible.
>
> Does the QT back-end need to be compiled against QT? or is it
> python-only?