I think it is because your Test() class is not subclassed from "object". Of
course, I have no clue why that would be an issue, but I have seen stranger
things when not subclassing from object.

On Fri, Nov 7, 2014 at 9:31 AM, rouckas <stepan.rou...@gmail.com> wrote:

> I have a little update on the issue: I tried it with different versions of
> python and matplotlib and it is still present in
> python 2.7.6 + matplotlib 1.4.2
>
> but it works as expected in
> python 3.4.0 + matplotlib 1.4.2
>
> Should this be reported as a bug in matplotlib 1.4.2 on python 2.7.6?
>
> BTW, I noticed that my minimal text from previous mail didn't get through
> to
> the mailing list, so I am attaching it again (modified for python 2.7)
> without formatting:
>
> from __future__ import print_function
> import sys
> if sys.version_info < (3, 0):
>     import Tkinter as tk
> else:
>     import tkinter as tk
> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
> import matplotlib.figure as mplfig
>
>
> class Test:
>     def on_press(self, event):
>         print("clicked2")
>
>     def connect(self, canvas):
>         self.cidpress = canvas.mpl_connect(
>                 'button_press_event', self.on_press)
>         self.cidpress = canvas.mpl_connect(
>                 'button_press_event', lambda event: print("clicked1"))
>
> class App(object):
>     def on_press(self, event):
>         print("clicked0")
>     def __init__(self, master):
>         self.fig = mplfig.Figure()
>         self.canvas = FigureCanvasTkAgg(self.fig, master=master)
>
>         dl = Test()
>         dl.connect(self.canvas)
>
>         self.cidpress = self.canvas.mpl_connect(
>                 'button_press_event', self.on_press)
>
>         self.canvas.get_tk_widget().pack()
>         self.canvas.draw()
>
> if __name__ == "__main__":
>     root = tk.Tk()
>     app = App(root)
>     tk.mainloop()
>
> this should print
> clicked2
> clicked1
> clicked0
>
> after each click on the canvas. But in python 2.7.6 it prints only
> clicked1
> clicked0
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/Problem-with-event-handling-in-matplotlib-in-tkinter-tp44302p44307.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to