On Nov 9, 2007 12:37 PM, John Hunter <[EMAIL PROTECTED]> wrote:
> On Nov 8, 2007 7:48 PM, sunzen w. <[EMAIL PROTECTED]> wrote:
> > Mike,
> > Thank you for your suggestion.
> > I found that pan mode doesn't work as expected in page of notebook.
> > The sample code is attached.
> > Thanks for your further guidance in advance.
>
>
> Now that is a well focused question.  A little googling revealed that
> when a gtk drawing area (eg an matplotlib canvas) is placed in a gtk
> notebook, it needs to have the focus to receive key press events.
>
>   http://www.daa.com.au/pipermail/pygtk/2002-August/003190.html
>
> I had hoped it would be enough to do
>
>   canvas.grab_focus()
>
> but apparently it is not (upon testing).  But the suggestion from the
> link above to use TAB to grab the focus worked in my tests.

With a little more testing, I find if I grab the focus after showing
the window that the notebook is in, it works as expected:

        notebook = gtk.Notebook()
        win.add(notebook)

        vbox = gtk.VBox()
        fig = mplfigure.Figure(figsize=(5,4), dpi=100)
        canvas = FigureCanvas(fig)  # a gtk.DrawingArea

        vbox.pack_start(canvas)
        toolbar = NavigationToolbar(canvas, win)
        vbox.pack_start(toolbar, False, False)

        notebook.insert_page(vbox, gtk.Label('Graph'))

        win.show_all()

        # need to get the focus in a notebook to handle keypress
        # events
        canvas.grab_focus()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to