i want to use multiple matplotlib canvasses which contain data + a (matplotlib) slider widget. the problem is that the slider widgets are not updating correctly (looks like the mouse events are not sent or something)
this is what i have:
import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.figure import Figure from matplotlib.widgets import Slider class PlotWidget( Tk.Frame ): def __init__(self, master): Tk.Frame.__init__(self, master) self.figure = Figure(figsize=(5,4), dpi=75) self.canvas = FigureCanvasTkAgg(self.figure, self) self.frame = self.canvas.get_tk_widget() self.frame.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) self.canvas.show() def add_slider(self): a = self.figure.add_axes([0.25, 0.1, 0.65, 0.03], axisbg='lightgoldenrodyellow') s = Slider( a, 'range', 0.1, 30.0, valinit=5) self.canvas.show() root = Tk.Tk() option = 1 if option == 1 or option = 2: w = PlotWidget(root) w.pack() figure = w.figure else: f = Tk.Frame(root, bd = 6, bg='red') figure = matplotlib.figure.Figure(figsize=(5,4), dpi=75) canvas = FigureCanvasTkAgg(figure, f) canvas.get_tk_widget().pack() canvas.show() f.pack() if option = 1: w.add_slider() else: a = figure.add_axes([0.25, 0.1, 0.65, 0.03], axisbg='lightgoldenrodyellow') s = Slider( a, 'range', 0.1, 30.0, valinit=5) Tk.mainloop() option 1 does not work all other combinations do (in the test script atleast, in my application it also does not work when i create the slider widget in another location. the slider does not react on the mouse events.....
what am i missing?!