Hi guys,

I'm new to Python have get done a lot by searching. Now I try to bind a scroll wheel to canvas, but it doesn't do anything. Will someone look at the code what I do wrong?
I tried to keep my snippet clean. Hope It's enough.

class Viewer(tk.Toplevel):
    def __init__(self, master, listBoxValue):
        tk.Toplevel.__init__(self, master)

        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        cnv = Canvas(self)
        cnv.grid(row=0, column=0, sticky='nswe')
        vScroll = Scrollbar(self, orient=VERTICAL, command=cnv.yview)
        vScroll.grid(row=0, column=1, sticky='ns')
        frm = Frame(cnv)
        cnv.create_window(0, 0, window=frm, anchor='nw')
        cnv.bind_all('<MouseWheel>', lambda event: self.on_vertical)

    #select data from database
        #loop through rows
            #Label(frm, image=image) # attach image to frame

    cnv.configure(scrollregion=(0, 0, frm.winfo_width(), frm.winfo_height() + 40))

    def on_vertical(self, event):
        self.cnv.yview_scroll(-1 * event.delta, 'units')

Code looks incomplete. (it is) Without the rest not much to work with.

Try putting it in a fiddle if you can, like http://pythonfiddle.com/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.