Skip to content

Commit 9d2b5ad

Browse files
committed
Read the arguments of _xview and _yview explicitly
1 parent 082cfb8 commit 9d2b5ad

File tree

1 file changed

+12
-8
lines changed
  • src/ScrollableContainers

1 file changed

+12
-8
lines changed

src/ScrollableContainers/_tk.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, *args, **kwargs):
5757
self._canvas.yview_moveto(0.0)
5858

5959
@property
60-
def frame(self):
60+
def frame(self) -> ttk.Frame:
6161
return self._frame
6262

6363
def _show_scrollbars(self):
@@ -109,7 +109,7 @@ def _peek_scrollbars(self, _event: tk.Event | None = None):
109109
self._show_scrollbars()
110110
self._schedule_hide_scrollbars()
111111

112-
def _xview(self, *args, width: int | None = None):
112+
def _xview(self, action: str, fraction_or_amount: float | int, what: str | None = None, *, width: int | None = None):
113113
"""
114114
Called when a horizontal scroll is requested. Called by other callbacks
115115
(``_configure_viewport_explicit`` and ``_configure_viewport_implicit``)
@@ -118,11 +118,13 @@ def _xview(self, *args, width: int | None = None):
118118
horizontal dimension. Otherwise, horizontally centre the contents of
119119
the canvas.
120120
121-
:param args: Passed to ``tkinter.Canvas.xview``.
122-
:param width: Width of the canvas.
121+
:param action: First argument of ``tkinter.Canvas.xview``.
122+
:param fraction_or_amount: Second argument of ``tkinter.Canvas.xview``.
123+
:param what: Third argument of ``tkinter.Canvas.xview``.
124+
:param width: Width of the canvas. Will be queried if ``None``.
123125
"""
124126
if self._canvas.xview() != (0.0, 1.0):
125-
self._canvas.xview(*args)
127+
self._canvas.xview(action, fraction_or_amount, what)
126128
else:
127129
width = width or self._canvas.winfo_width()
128130

@@ -133,15 +135,17 @@ def _xview(self, *args, width: int | None = None):
133135
self._canvas.xview_moveto((1 - width / self._frame.winfo_width()) / 2)
134136
self._peek_scrollbars()
135137

136-
def _yview(self, *args):
138+
def _yview(self, action:str,fraction_or_amount:float|int,what:str|None=None):
137139
"""
138140
Called when a vertical scroll is requested. Scroll the viewport only if
139141
it does not show everything in the vertical dimension.
140142
141-
:param args: Passed to ``tkinter.Canvas.yview``.
143+
:param action: First argument of ``tkinter.Canvas.yview``.
144+
:param fraction_or_amount: Second argument of ``tkinter.Canvas.yview``.
145+
:param what: Third argument of ``tkinter.Canvas.yview``.
142146
"""
143147
if self._canvas.yview() != (0.0, 1.0):
144-
self._canvas.yview(*args)
148+
self._canvas.yview(action,fraction_or_amount,what)
145149
self._peek_scrollbars()
146150

147151
def _configure_viewport_explicit(self, event: tk.Event):

0 commit comments

Comments
 (0)