fix scrollbar

This commit is contained in:
vincent 2018-08-26 20:22:48 +02:00
parent f1dbacc033
commit ccb5b80d6d

View File

@ -35,7 +35,7 @@ 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)) self.canvas=canvas=Canvas(self,width=300,height=300,scrollregion=(0,0,500,500))
vbar=Scrollbar(self,orient=VERTICAL) vbar=Scrollbar(self,orient=VERTICAL)
vbar.pack(side=RIGHT, fill=Y) vbar.pack(side=RIGHT, fill=Y)
@ -54,7 +54,6 @@ class ScrollableCanvas(Frame):
# update the scrollbars to match the size of the inner frame # update the scrollbars to match the size of the inner frame
size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
canvas.config(scrollregion="0 0 %s %s" % size) canvas.config(scrollregion="0 0 %s %s" % size)
canvas.yview_moveto(1)
if interior.winfo_reqwidth() != canvas.winfo_width(): if interior.winfo_reqwidth() != canvas.winfo_width():
# update the canvas's width to fit the inner frame # update the canvas's width to fit the inner frame
canvas.config(width=interior.winfo_reqwidth()) canvas.config(width=interior.winfo_reqwidth())
@ -67,8 +66,9 @@ class ScrollableCanvas(Frame):
canvas.bind('<Configure>', _configure_canvas) canvas.bind('<Configure>', _configure_canvas)
def _MouseWhell(event): def _MouseWhell(event):
print (event.delta/120)
canvas.yview_scroll(-1*(event.delta/120), "units") canvas.yview_scroll(-1*(event.delta/120), "units")
self.bind_all("<MouseWheel>",_MouseWhell) self.bind("<MouseWheel>",_MouseWhell)
@ -149,6 +149,7 @@ class Interface:
print("numero de chaine inconnue") print("numero de chaine inconnue")
unknow=Label(self.resultframe.interior, text="numero de chaine inconnue") unknow=Label(self.resultframe.interior, text="numero de chaine inconnue")
unknow.pack() unknow.pack()
self.resultframe.canvas.yview_moveto(1)
self.value.set("") self.value.set("")