diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9d3182..958ffbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,20 +3,17 @@ on: [push, workflow_dispatch] jobs: build: - name: lint, install and package on amd64/archlinux:base runs-on: ubuntu-22.04 container: amd64/archlinux:base steps: - uses: actions/checkout@v4 - run: | - pacman -Syu --needed --noconfirm python-pipx python-wxpython - pipx install hatch - pipx ensurepath + pacman -Syu --needed --noconfirm python-pipx python-pyqt5 python-pyqt6 python-wxpython + pipx install --global hatch name: Install dependencies - # Use the full path because Hatch is not found for some reason. - - run: ~/.local/bin/hatch fmt --check + - run: hatch fmt --check name: Lint - - run: ~/.local/bin/hatch -vv env create dev + - run: hatch -vv env create dev name: Create editable installation - - run: ~/.local/bin/hatch build + - run: hatch build name: Package into tarball and wheel diff --git a/src/ScrollableContainers/_tk.py b/src/ScrollableContainers/_tk.py index b8cdf44..efb93eb 100644 --- a/src/ScrollableContainers/_tk.py +++ b/src/ScrollableContainers/_tk.py @@ -57,7 +57,7 @@ def __init__(self, *args, **kwargs): self._canvas.yview_moveto(0.0) @property - def frame(self): + def frame(self) -> ttk.Frame: return self._frame def _show_scrollbars(self): @@ -109,7 +109,7 @@ def _peek_scrollbars(self, _event: tk.Event | None = None): self._show_scrollbars() self._schedule_hide_scrollbars() - def _xview(self, *args, width: int | None = None): + def _xview(self, action: str, fraction_or_amount: float, what: str | None = None, *, width: int | None = None): """ Called when a horizontal scroll is requested. Called by other callbacks (``_configure_viewport_explicit`` and ``_configure_viewport_implicit``) @@ -118,11 +118,13 @@ def _xview(self, *args, width: int | None = None): horizontal dimension. Otherwise, horizontally centre the contents of the canvas. - :param args: Passed to ``tkinter.Canvas.xview``. - :param width: Width of the canvas. + :param action: First argument of ``tkinter.Canvas.xview``. + :param fraction_or_amount: Second argument of ``tkinter.Canvas.xview``. + :param what: Third argument of ``tkinter.Canvas.xview``. + :param width: Width of the canvas. Will be queried if ``None``. """ if self._canvas.xview() != (0.0, 1.0): - self._canvas.xview(*args) + self._canvas.xview(action, fraction_or_amount, what) else: width = width or self._canvas.winfo_width() @@ -133,15 +135,17 @@ def _xview(self, *args, width: int | None = None): self._canvas.xview_moveto((1 - width / self._frame.winfo_width()) / 2) self._peek_scrollbars() - def _yview(self, *args): + def _yview(self, action: str, fraction_or_amount: float, what: str | None = None): """ Called when a vertical scroll is requested. Scroll the viewport only if it does not show everything in the vertical dimension. - :param args: Passed to ``tkinter.Canvas.yview``. + :param action: First argument of ``tkinter.Canvas.yview``. + :param fraction_or_amount: Second argument of ``tkinter.Canvas.yview``. + :param what: Third argument of ``tkinter.Canvas.yview``. """ if self._canvas.yview() != (0.0, 1.0): - self._canvas.yview(*args) + self._canvas.yview(action, fraction_or_amount, what) self._peek_scrollbars() def _configure_viewport_explicit(self, event: tk.Event):