[Matplotlib-users] Cannot get key_press_event to work with gtk builder
Hi I have tried the mpl and glade examples and tried different approaches from the net, but I can only get button_press_event to work with a matplot canvas. key_press_event does not work using gtkagg for GUI. Is this due to the gtk builder 2.16? I mean does the main window steal the key_presses or something? I had previously tried an example without a gtk gui (don't remember the example). There a callback was connected and it could get events containing both mouse click and keypress. I mean if I pressed the mouse button while keeping doen say 'e' I could get form event.key that 'e' was pressed when I click the mouse. I have to use gtk for the rest of the GUI so when I tried to pack the canvas into gtk I got the problem that callbacks and connections didn't work. i guess it has to do with that gtk has it's own callback system. If anybody has some example code, tips or tricks, I would very much appreciate that. I cannot at the moment provide an example code due to project deadline, but will do afterwards. thanks in advance Preben -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot moves while using the "Zoom to rectangle" button
> On 07/13/2010 02:05 AM, John Hunter wrote: >> I also see buggy behavior, but on my ubuntu linux system I see that >> the whole subplot gets painted black on a mouse press and remains so >> while the rubber-banding is in effect. It's not strictly black, but >> it looks like blackish bit noise. I also notice if I don't add the >> combobox to the vbox, I have no problem. But I don't see that the >> "plot moves" > > By the plot moves, I mean that with a reasonably sized control on top of > the plot the lower x axis seems to shoot upward during the zoom. See the > attached example. I see the same moving on one of my PCs (64-bit) in Ubuntu 10.04. But the movement is much larger. -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problems with pygtk and matplotlib
On Sun, 11 Jul 2010 13:39:05 -1000 Eric Firing wrote: > On 07/11/2010 07:52 AM, Preben Randhol wrote: > > >> > >> Also, are you using backend_gtk or backend_gtkagg (and does it > >> matter for your problem?) > > > > I use GTKAgg and it works. GTK doesn't. > > > > backend_gtk has limitations that backend_gtkagg does not, although I > don't know that your zooming problem should be one of them. Are you > sure you *need* to use backend_gtk instead of backend_gtkagg? But I am using gtkagg. I only tested backend_gtk because I was asked to. gtkagg still has problem with zooming/panning Preben -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problems with pygtk and matplotlib
On Fri, 9 Jul 2010 19:37:56 -0500 John Hunter wrote: > On Fri, Jul 9, 2010 at 3:10 PM, Preben Randhol > wrote: > > > I'm trying to plot several subplots. I have setup a scrollwidget and > > viewport and I pack a canvas into a vbox in the viewport. > > > > Problem is that when I scroll, either some of the subplots are > > missing, or I get an error when I try to zoom on a graph that > > argument is not a gdk.gtk.image (or something like that) but None. > > > > I thought this was fixed in 1.0, but it isn't > > > > Please advice! > > Does this example work for you? > > > http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_gtk3.html Yes it works and a bit cleanup of my imports helped in my program too. However if I add NavigateToolbar to the example above I get problems. mtoolbar = NavigationToolbar(canvas, win) then I get error when I try to zoom in a graph: /usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py:621: DeprecationWarning: Use the new widget gtk.Tooltip self.tooltips = gtk.Tooltips() /usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py:601: GtkWarning: gdk_drawable_copy_to_image: assertion `src_y >= 0' failed self._imageBack = axrect, drawable.get_image(*axrect) Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py", line 606, in idle_draw drawable.draw_image(gc, imageBack, 0, 0, *lastrect) TypeError: Gdk.Drawable.draw_image() argument 2 must be gtk.gdk.Image, not None The graph zooms, but I don't see the rubberband. I got same error in 1.0: TypeError: Gdk.Drawable.draw_image() argument 2 must be gtk.gdk.Image, not None > It uses a ScrolledWindow. > > Also, are you using backend_gtk or backend_gtkagg (and does it matter > for your problem?) I use GTKAgg and it works. GTK doesn't. > > If you could create a minimal example starting with > embedding_in_gtk3.py that replicates your problem, we're more likely > to be able to help. I have added the example above with my changes. Zooming is the problem. #!/usr/bin/env python """ demonstrate adding a FigureCanvasGTK/GTKAgg widget to a gtk.ScrolledWindow """ import gtk from matplotlib.figure import Figure from numpy import arange, sin, pi # uncomment to select /GTK/GTKAgg/GTKCairo #from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas #from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar win = gtk.Window() win.connect("destroy", lambda x: gtk.main_quit()) win.set_default_size(400,300) win.set_title("Embedding in GTK") f = Figure(figsize=(5,4), dpi=100) a = f.add_subplot(511) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) a = f.add_subplot(512) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) a = f.add_subplot(513) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) a = f.add_subplot(514) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) a = f.add_subplot(515) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) sw = gtk.ScrolledWindow() cx=gtk.VBox() win.add (cx) cx.pack_start(sw) # A scrolled window border goes outside the scrollbars and viewport sw.set_border_width (10) # policy: ALWAYS, AUTOMATIC, NEVER sw.set_policy (hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_ALWAYS) canvas = FigureCanvas(f) # a gtk.DrawingArea canvas.set_size_request(800,3000) bx=gtk.VBox() mtoolbar = NavigationToolbar(canvas, win) cx.pack_start(mtoolbar,False,False) sw.add_with_viewport (bx) bx.pack_start(canvas,True, True) win.show_all() gtk.main() -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Problems with pygtk and matplotlib
Hi I'm trying to plot several subplots. I have setup a scrollwidget and viewport and I pack a canvas into a vbox in the viewport. Problem is that when I scroll, either some of the subplots are missing, or I get an error when I try to zoom on a graph that argument is not a gdk.gtk.image (or something like that) but None. I thought this was fixed in 1.0, but it isn't Please advice! Thanks in advance. Preben -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Reverse y-axis?
Hi I need to plot some data vs depth. In stead of giving depths as 0,-1000,-2000, I want to give the depths as 0,1000,2000 but when plotting the data goes downwards (as if they had been negative). Can I get the y-axis to reverse so it goes downwards and not upwards? -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users