Skip to content

No "scroll_event" when using Gtk3 backends #2668

Closed
@pbirnzain

Description

@pbirnzain

In Gtk3 applications using pygobject, scrolling does not seem to work in matplotlib widgets. While each button_press_event is registered normally, there are no scroll_events. For all other widgets, scrolling works normally.

I tried both the Gtk3Agg and Gtk3cairo backends without success, it does work with pygtk and the gtkagg backend though.
I've attached a simple example program [4] to illustrate the problem. To test with different backends, simply use the appropriate imports: [1][2][3]

[1] pygtk imports:

import gtk as Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigCanvas

[2] Gtk3agg imports:

from gi.repository import Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigCanvas

[3] Gtk3cairo imports:

from gi.repository import Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigCanvas

[4] Code of example except imports:

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions