66
77__all__ = ['ScrollableFrameTk' ]
88
9+ _system = platform .system ()
10+
911###############################################################################
1012
1113class ScrollableFrameTk (ttk .Frame ):
@@ -43,8 +45,8 @@ def __init__(self, *args, **kwargs):
4345 # Initially, the vertical scrollbar is a hair below its topmost
4446 # position. Move it to said position. No harm in doing the equivalent
4547 # for the horizontal scrollbar.
46- self ._canvas .xview_moveto (0 )
47- self ._canvas .yview_moveto (0 )
48+ self ._canvas .xview_moveto (0.0 )
49+ self ._canvas .yview_moveto (0.0 )
4850
4951 ###########################################################################
5052
@@ -165,9 +167,9 @@ def _on_leave(self, event=None):
165167 def _on_mouse_scroll (self , event ):
166168 '''
167169Called when the mouse wheel is scrolled or a two-finger swipe gesture is
168- performed on the touchpad. Ask to scroll the view horizontally if Shift is held
169- down (equivalent to a horizontal two-finger swipe) and vertically otherwise
170- (equivalent to a vertical two-finger swipe).
170+ performed on the touchpad. Ask to scroll the view horizontally if the mouse
171+ wheel is scrolled with Shift held down (equivalent to a horizontal two-finger
172+ swipe) and vertically otherwise (equivalent to a vertical two-finger swipe).
171173
172174:param event: Scroll event.
173175 '''
@@ -179,13 +181,12 @@ def _on_mouse_scroll(self, event):
179181 else :
180182 callee = self ._yview
181183
182- system = platform .system ()
183- if system == 'Linux' :
184+ if _system == 'Linux' :
184185 if event .num == 4 :
185186 callee (tk .SCROLL , - 1 , tk .UNITS )
186187 elif event .num == 5 :
187188 callee (tk .SCROLL , 1 , tk .UNITS )
188- elif system == 'Darwin' :
189+ elif _system == 'Darwin' :
189190 callee (tk .SCROLL , - event .delta , tk .UNITS )
190- elif system == 'Windows' :
191+ elif _system == 'Windows' :
191192 callee (tk .SCROLL , - event .delta // 120 , tk .UNITS )
0 commit comments