qt backend fixes

Hi John,

I'm one the developers at JPL who worked on the Qt backend. Below are diffs for a couple of minor mods to the Qt backend. They:

1) fix a bug where keyboard input was grabbed by the figure
    and not released.
2) turn on cursor changes.
3) clean up a typo and commented-out print statement.

Please add them to backend_qt.py at your convenience.

Thanks,

Michael

···

========================================================================
  Michael Brady
  Jet Propulsion Laboratory (M/S 301-140L)
  4800 Oak Grove Drive
  Pasadena, CA 91109 ========================================================================

--- /home/mbrady/matplotlib-cvs/matplotlib/lib/matplotlib/backends/backend_qt.py 2005-03-01 07:53:17.000000000 -0800
+++ backend_qt.py 2005-04-13 11:32:11.000000000 -0700
@@ -15,7 +15,7 @@
  from matplotlib.mathtext import math_parse_s_ft2font
  import qt

-backend_version = "0.9"
+backend_version = "0.9.1"
  def fn_name(): return sys._getframe(1).f_code.co_name

  DEBUG = False
@@ -88,10 +88,9 @@
          x = event.pos().x()
          # flipy so y=0 is bottom of canvas
          y = self.figure.bbox.height() - event.pos().y()
- #print 'event.button()', event.button()
          button = self.buttond[event.button()]
          FigureCanvasBase.button_press_event( self, x, y, button )
- if DEBUG: print 'button pressed'
+ if DEBUG: print 'button pressed:', event.button()

      def mouseMoveEvent( self, event ):
          x = event.x()
@@ -104,7 +103,7 @@
          x = event.x()
          # flipy so y=0 is bottom of canvas
          y = self.figure.bbox.height() - event.y()
- button = button = self.buttond[event.button()]
+ button = self.buttond[event.button()]
          FigureCanvasBase.button_release_event( self, x, y, button )
          if DEBUG: print 'button released'
          self.draw()
@@ -147,7 +146,8 @@

          self.canvas.reparent( self.window, qt.QPoint( 0, 0 ) )
          # Give the keyboard focus to the figure instead of the manager
- self.canvas.grabKeyboard()
+ self.canvas.setFocusPolicy( qt.QWidget.ClickFocus )
+ self.canvas.setFocus()
          self.window.setCaption( "Figure %d" % num )
          self.window.setCentralWidget( self.canvas )

@@ -227,8 +227,8 @@

      def set_cursor( self, cursor ):
          if DEBUG: print 'Set cursor' , cursor
- #qt.QApplication.restoreOverrideCursor()
- #qt.QApplication.setOverrideCursor( qt.QCursor( cursord[cursor] ) )
+ qt.QApplication.restoreOverrideCursor()
+ qt.QApplication.setOverrideCursor( qt.QCursor( cursord[cursor] ) )

      def draw_rubberband( self, event, x0, y0, x1, y1 ):
          height = self.canvas.figure.bbox.height()
@@ -242,12 +242,9 @@
          self.canvas.drawRectangle( rect )

      def save_figure( self ):
- self.canvas.releaseKeyboard()
          fname = qt.QFileDialog.getSaveFileName()
-
          if fname:
              self.canvas.print_figure( fname.latin1() )
- self.canvas.grabKeyboard()

  # set icon used when windows are minimized
  try: