Hello everyone,

so I've run into a bit of a problem while embedding a matplotlib plot
into a GTK3 application. Everything's working fine as always, except
the scroll_event seems to get stuck somewhere and my callback is never
called. The button_press_event works.

Apologies in advance if I missed something, but something somewhere
doesn't seem to be quite right. Please let me know if I need to file a
bug report?

Minimal example to demonstrate the problem: [1]
With pyplot it works just fine: [2]

Regards,
Patrick


[1] GTK3Agg minimal example
from gi.repository import Gtk, Gdk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigCanvas

def on_press(canvas, event):
        print "press!"

def on_scroll(canvas, event):
        print "scroll!"

window = Gtk.Window()
window.connect("delete-event", Gtk.main_quit)

figure = Figure(figsize=(5,4), dpi=100)
plot = figure.add_subplot(111)
plot.plot([0,0.5,2])

canvas = FigCanvas(figure)
canvas.connect('button_press_event', on_press)
canvas.connect('scroll_event', on_scroll)

window.add(canvas)
window.show_all()
Gtk.main()

[2] pyplot minimal example
import matplotlib.pyplot as plt

plt.plot([0,0.5,2])
fig = plt.gcf()

def on_click(event):
        print "press!"

def on_scroll(event):
        print "scroll!"

fig.canvas.mpl_connect('button_press_event', on_click)
fig.canvas.mpl_connect('scroll_event', on_scroll)

plt.show()

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to