1010class ScrollableFrameTk (ttk .Frame ):
1111 """
1212 Container with horizontal and vertical scrolling capabilities. Widgets must
13- be added to its `frame` attribute.
13+ be added to its ``frame`` attribute. Constructor arguments are passed to
14+ the parent constructor.
1415 """
1516
1617 def __init__ (self , * args , ** kwargs ):
@@ -45,16 +46,16 @@ def __init__(self, *args, **kwargs):
4546 self ._canvas .xview_moveto (0.0 )
4647 self ._canvas .yview_moveto (0.0 )
4748
48- def _xview (self , * args , width = None ):
49+ def _xview (self , * args , width : int | None = None ):
4950 """
5051 Called when a horizontal scroll is requested. Called by other callbacks
51- (`_on_canvas_configure` and `_on_frame_configure`) whenever it is
52+ (`` _on_canvas_configure`` and `` _on_frame_configure` `) whenever it is
5253 necessary to horizontally realign the contents of the canvas. Scroll
5354 the view only if the contents are not completely visible. Otherwise,
5455 move the scrollbar to such a position that they are horizontally
5556 centred.
5657
57- :param args: Tuple which can be passed to `tkinter.Canvas.xview`.
58+ :param args: Passed to `` tkinter.Canvas.xview` `.
5859 :param width: Width of the canvas.
5960 """
6061 if self ._canvas .xview () != (0.0 , 1.0 ):
@@ -73,12 +74,12 @@ def _yview(self, *args):
7374 Called when a vertical scroll is requested. Scroll the view only if the
7475 contents are not completely visible.
7576
76- :param args: Tuple which can be passed to `tkinter.Canvas.yview`.
77+ :param args: Passed to `` tkinter.Canvas.yview` `.
7778 """
7879 if self ._canvas .yview () != (0.0 , 1.0 ):
7980 self ._canvas .yview (* args )
8081
81- def _on_canvas_configure (self , event ):
82+ def _on_canvas_configure (self , event : tk . Event ):
8283 """
8384 Called when the canvas is resized. Update the scrollable region.
8485
@@ -87,22 +88,22 @@ def _on_canvas_configure(self, event):
8788 self ._canvas .configure (scrollregion = self ._canvas .bbox (tk .ALL ))
8889 self ._xview (tk .SCROLL , 0 , tk .UNITS , width = event .width )
8990
90- def _on_frame_configure (self , _ = None ):
91+ def _on_frame_configure (self , _event : tk . Event | None = None ):
9192 """
9293 Called when the frame is resized or the canvas is scrolled. Update the
9394 scrollable region.
9495
9596 This method is necessary to handle updates which may occur after the
9697 GUI loop has started.
9798
98- :param _ : Configure event.
99+ :param _event : Configure event.
99100 """
100101 self ._canvas .configure (scrollregion = self ._canvas .bbox (tk .ALL ))
101102 self ._xview (tk .SCROLL , 0 , tk .UNITS )
102103
103- def _on_frame_expose (self , _ = None ):
104+ def _on_frame_expose (self , _event : tk . Event | None = None ):
104105 """
105- Called when the frame becomes visible. Call `_on_frame_configure` and
106+ Called when the frame becomes visible. Call `` _on_frame_configure` ` and
106107 then disable this callback.
107108
108109 This method is necessary because if a scrollable frame is put into,
@@ -112,34 +113,34 @@ def _on_frame_expose(self, _=None):
112113 because its frame configure events work differently.) Hence, I try to
113114 centre the contents again upon an expose event.
114115
115- :param _ : Expose event.
116+ :param _event : Expose event.
116117 """
117118 self ._on_frame_configure ()
118119 self .frame .unbind ("<Expose>" , self ._on_frame_expose_id )
119120
120- def _on_canvas_enter (self , _ = None ):
121+ def _on_canvas_enter (self , _event : tk . Event | None = None ):
121122 """
122123 Called when the mouse pointer enters the canvas. Set up vertical
123124 scrolling with the mouse wheel.
124125
125- :param _ : Enter event.
126+ :param _event : Enter event.
126127 """
127128 self .bind_all ("<Button-4>" , self ._on_mouse_scroll )
128129 self .bind_all ("<Button-5>" , self ._on_mouse_scroll )
129130 self .bind_all ("<MouseWheel>" , self ._on_mouse_scroll )
130131
131- def _on_canvas_leave (self , _ = None ):
132+ def _on_canvas_leave (self , _event : tk . Event | None = None ):
132133 """
133134 Called when the mouse pointer leaves the canvas. Unset vertical
134135 scrolling with the mouse wheel.
135136
136- :param _ : Leave event.
137+ :param _event : Leave event.
137138 """
138139 self .unbind_all ("<Button-4>" )
139140 self .unbind_all ("<Button-5>" )
140141 self .unbind_all ("<MouseWheel>" )
141142
142- def _on_mouse_scroll (self , event ):
143+ def _on_mouse_scroll (self , event : tk . Event ):
143144 """
144145 Called when the mouse wheel is scrolled or a two-finger swipe gesture
145146 is performed on the touchpad. Ask to scroll the view horizontally if
0 commit comments