add bind mouse wheell
This commit is contained in:
parent
e2ab64172e
commit
b25249cb29
71
chaineTV.py
71
chaineTV.py
@ -32,39 +32,46 @@ class LabelImage(Label):
|
|||||||
|
|
||||||
|
|
||||||
class ScrollableCanvas(Frame):
|
class ScrollableCanvas(Frame):
|
||||||
def __init__(self, parent, *args, **kw):
|
def __init__(self, parent, *args, **kw):
|
||||||
Frame.__init__(self, parent, *args, **kw)
|
Frame.__init__(self, parent, *args, **kw)
|
||||||
|
|
||||||
canvas=Canvas(self,width=300,height=300,scrollregion=(0,0,500,500))
|
canvas=Canvas(self,width=300,height=300,scrollregion=(0,0,500,500))
|
||||||
|
|
||||||
vbar=Scrollbar(self,orient=VERTICAL)
|
|
||||||
vbar.pack(side=RIGHT, fill=Y)
|
|
||||||
vbar.config(command=canvas.yview)
|
|
||||||
|
|
||||||
canvas.config(width=200,height=200)
|
|
||||||
canvas.config(yscrollcommand=vbar.set)
|
|
||||||
canvas.pack(side=LEFT,expand=True,fill=BOTH)
|
|
||||||
|
|
||||||
# create a frame inside the canvas which will be scrolled with it
|
|
||||||
self.interior = interior = Frame(canvas)
|
|
||||||
interior_id = canvas.create_window(0, 0, window=interior, anchor=NW )
|
|
||||||
# track changes to the canvas and frame width and sync them,
|
|
||||||
# also updating the scrollbar
|
|
||||||
def _configure_interior(event):
|
|
||||||
# update the scrollbars to match the size of the inner frame
|
|
||||||
size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
|
|
||||||
canvas.config(scrollregion="0 0 %s %s" % size)
|
|
||||||
if interior.winfo_reqwidth() != canvas.winfo_width():
|
|
||||||
# update the canvas's width to fit the inner frame
|
|
||||||
canvas.config(width=interior.winfo_reqwidth())
|
|
||||||
interior.bind('<Configure>', _configure_interior)
|
|
||||||
|
|
||||||
def _configure_canvas(event):
|
|
||||||
if interior.winfo_reqwidth() != canvas.winfo_width():
|
|
||||||
# update the inner frame's width to fill the canvas
|
|
||||||
canvas.itemconfigure(interior_id, width=canvas.winfo_width())
|
|
||||||
canvas.bind('<Configure>', _configure_canvas)
|
|
||||||
|
|
||||||
|
vbar=Scrollbar(self,orient=VERTICAL)
|
||||||
|
vbar.pack(side=RIGHT, fill=Y)
|
||||||
|
vbar.config(command=canvas.yview)
|
||||||
|
|
||||||
|
canvas.config(width=200,height=200)
|
||||||
|
canvas.config(yscrollcommand=vbar.set)
|
||||||
|
canvas.pack(side=LEFT,expand=True,fill=BOTH)
|
||||||
|
|
||||||
|
# create a frame inside the canvas which will be scrolled with it
|
||||||
|
self.interior = interior = Frame(canvas)
|
||||||
|
interior_id = canvas.create_window(0, 0, window=interior, anchor=NW )
|
||||||
|
# track changes to the canvas and frame width and sync them,
|
||||||
|
# also updating the scrollbar
|
||||||
|
def _configure_interior(event):
|
||||||
|
# update the scrollbars to match the size of the inner frame
|
||||||
|
size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
|
||||||
|
canvas.config(scrollregion="0 0 %s %s" % size)
|
||||||
|
canvas.yview_moveto(1)
|
||||||
|
if interior.winfo_reqwidth() != canvas.winfo_width():
|
||||||
|
# update the canvas's width to fit the inner frame
|
||||||
|
canvas.config(width=interior.winfo_reqwidth())
|
||||||
|
interior.bind('<Configure>', _configure_interior)
|
||||||
|
|
||||||
|
def _configure_canvas(event):
|
||||||
|
if interior.winfo_reqwidth() != canvas.winfo_width():
|
||||||
|
# update the inner frame's width to fill the canvas
|
||||||
|
canvas.itemconfigure(interior_id, width=canvas.winfo_width())
|
||||||
|
canvas.bind('<Configure>', _configure_canvas)
|
||||||
|
|
||||||
|
def _MouseWhell(event):
|
||||||
|
canvas.yview_scroll(-1*(event.delta/120), "units")
|
||||||
|
self.bind_all("<MouseWheel>",_MouseWhell)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class emmisionGUI(Frame):
|
class emmisionGUI(Frame):
|
||||||
def __init__(self,parent,**kwarg):
|
def __init__(self,parent,**kwarg):
|
||||||
Frame.__init__(self,parent)
|
Frame.__init__(self,parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user