Mar-25-2020, 09:04 AM
Hi,
I would like to make a widget to pass picture with scroll button. Below is my code however I cannot pass images while scroll button is working. Any idea how to change it? Thanks in advance.
I would like to make a widget to pass picture with scroll button. Below is my code however I cannot pass images while scroll button is working. Any idea how to change it? Thanks in advance.
root = tkinter.Tk() root.wm_title("Try MouseWheel") def imageShow(): global fig fig = Figure() fig.add_subplot().imshow(imageDim[:, :, slide], cmap='gray', vmin=minInt, vmax=maxInt) canvas = FigureCanvasTkAgg(fig, master=root) canvas.draw() canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand='true') root.bind("<MouseWheel>", mouse_wheel) def clearfig(): fig.clear() def mouse_wheel(event): global slide print(slide) # respond to Linux or Windows wheel event if event.num == 5 or event.delta == -120: slide -= 1 if event.num == 4 or event.delta == 120: slide += 1 clearfig() imageShow() root.mainloop()