[IPython-dev] Getting autorepeat keyboard events in ipython+matplotlib+PyQt4

Mark Voorhies mark.voorhies at ucsf.edu
Tue May 5 02:31:34 EDT 2015


I'm playing with an interactive dotplot based on a matplotlib figure created from an
IPython notebook (basically, an IPython/matplotlib port of
this: http://histo.ucsf.edu/BMS270/BMS270b_2013/code/pydotter_canopy.py)

I'm trying it with both the TkAgg backend and the qt backend (which is PyQt4 on my system).
In both cases, I'm binding keyboard and mouse events like this:

         # Disable default plot keybindings
         key_callbacks = self.fig.canvas.callbacks.callbacks[
             "key_press_event"].keys()
         for i in key_callbacks:
             self.fig.canvas.mpl_disconnect(i)
         # Substitute our own keybindings
         self.fig.canvas.mpl_connect("key_press_event", self.keypress)
         # For mouse clicks, we'll do our cross-hairs update in series
         # with the default mouse interactions
         self.fig.canvas.mpl_connect("button_press_event", self.click)

and in both cases, mouse clicks and single keypresses work.
For the qt backend, however, holding down a key only triggers a single event
(while it triggers repeated events for the TkAgg backend).

I'm initializing the qt backend at the top of the notebook like this:

%gui qt
%matplotlib qt

This is for IPython 2.3.1 (from git) on Kubuntu 14.04 with matplotlib 1.3.1-1ubuntu5

Has anyone run into this sort of thing?

Thanks,

--Mark



More information about the IPython-dev mailing list