From 9d2b5adce555575295352d2d40195678bac3073d Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:21:06 +0530 Subject: [PATCH 01/12] Read the arguments of `_xview` and `_yview` explicitly --- src/ScrollableContainers/_tk.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ScrollableContainers/_tk.py b/src/ScrollableContainers/_tk.py index b8cdf44..74cb35d 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 | int, 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|int,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): From c6609cacfdb5790b9c12f5c531ee661ad07855b1 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:23:40 +0530 Subject: [PATCH 02/12] Ruff lints --- src/ScrollableContainers/_tk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ScrollableContainers/_tk.py b/src/ScrollableContainers/_tk.py index 74cb35d..efb93eb 100644 --- a/src/ScrollableContainers/_tk.py +++ b/src/ScrollableContainers/_tk.py @@ -109,7 +109,7 @@ def _peek_scrollbars(self, _event: tk.Event | None = None): self._show_scrollbars() self._schedule_hide_scrollbars() - def _xview(self, action: str, fraction_or_amount: float | int, what: str | None = None, *, 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``) @@ -135,7 +135,7 @@ def _xview(self, action: str, fraction_or_amount: float | int, what: str | None self._canvas.xview_moveto((1 - width / self._frame.winfo_width()) / 2) self._peek_scrollbars() - def _yview(self, action:str,fraction_or_amount:float|int,what:str|None=None): + 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. @@ -145,7 +145,7 @@ def _yview(self, action:str,fraction_or_amount:float|int,what:str|None=None): :param what: Third argument of ``tkinter.Canvas.yview``. """ if self._canvas.yview() != (0.0, 1.0): - self._canvas.yview(action,fraction_or_amount,what) + self._canvas.yview(action, fraction_or_amount, what) self._peek_scrollbars() def _configure_viewport_explicit(self, event: tk.Event): From f6bcc0b4873d42c9205710436f4eacbbeee9c151 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:22:18 +0530 Subject: [PATCH 03/12] Install Hatch globally --- .github/workflows/{build.yml => ci.yml} | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) rename .github/workflows/{build.yml => ci.yml} (52%) diff --git a/.github/workflows/build.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/build.yml rename to .github/workflows/ci.yml index b9d3182..7e3dd04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/ci.yml @@ -1,22 +1,20 @@ -name: build +name: ci on: [push, workflow_dispatch] jobs: - build: - name: lint, install and package on amd64/archlinux:base + ci: + name: CI 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 + 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 From 98f91bf631295142863a74cf79644f1abb236575 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:29:51 +0530 Subject: [PATCH 04/12] Install more dependencies using `pacman` --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e3dd04..cc5e91f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,12 @@ on: [push, workflow_dispatch] jobs: ci: - name: CI 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 + pacman -Syu --needed --noconfirm python-pipx python-pyqt5 python-pyqt6 python-wxpython pipx install --global hatch name: Install dependencies - run: hatch fmt --check From 5d148ab3acc739dc96c590a64fed4a49901dfe08 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:32:06 +0530 Subject: [PATCH 05/12] Unit tests skeleton --- .github/workflows/ci.yml | 17 ++++++++++++++++- tests/test_tk.py | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/test_tk.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc5e91f..1e9f10f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: ci on: [push, workflow_dispatch] jobs: - ci: + build: runs-on: ubuntu-22.04 container: amd64/archlinux:base steps: @@ -17,3 +17,18 @@ jobs: name: Create editable installation - run: hatch build name: Package into tarball and wheel + + test: + strategy: + matrix: + runs-on: ['macos-13', 'macos-14', 'ubuntu-24.04', 'windows-2022'] + python-version: ['3.10', '3.11', '3.12', '3.13'] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: pipx install --global hatch + name: Install dependencies + - run: hatch test diff --git a/tests/test_tk.py b/tests/test_tk.py new file mode 100644 index 0000000..3a696e3 --- /dev/null +++ b/tests/test_tk.py @@ -0,0 +1,10 @@ +import unittest +import tkinter as tk +from ScrollableContainers import ScrollableFrameTk + +class TestTk(unittest.TestCase): + def setUp(self): + self.scrollable_frame = ScrollableFrameTk() + + def test_trivial(self): + assert True From 607ab166520b51fc73e5f51dc8e4726c5d11637e Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:34:44 +0530 Subject: [PATCH 06/12] Allow `assert` in tests --- pyproject.toml | 1 + tests/test_tk.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 59a8da0..85128a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,3 +37,4 @@ system-packages = true [tool.ruff.lint.per-file-ignores] "src/ScrollableContainers/__init__.py" = ["F401", "N999"] "src/ScrollableContainers/_tk.py" = ["PLR2004"] +"tests/**" = ["S101"] diff --git a/tests/test_tk.py b/tests/test_tk.py index 3a696e3..a189f13 100644 --- a/tests/test_tk.py +++ b/tests/test_tk.py @@ -1,7 +1,8 @@ import unittest -import tkinter as tk + from ScrollableContainers import ScrollableFrameTk + class TestTk(unittest.TestCase): def setUp(self): self.scrollable_frame = ScrollableFrameTk() From a36702137440b95d8f9e8c5871497bbcee26de7a Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:34:56 +0530 Subject: [PATCH 07/12] Added `tests/__init__.py` --- tests/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 From a8971b9a9118246ea83bed93040f53e4cb3ac1b6 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:35:59 +0530 Subject: [PATCH 08/12] `sudo pipx` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e9f10f..c1ba1ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - run: pipx install --global hatch + - run: sudo pipx install --global hatch name: Install dependencies - run: hatch test From 447247592170f9f6e7a4ec37fdf83c7ef6e8cd52 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:41:35 +0530 Subject: [PATCH 09/12] Run tests without Hatch --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1ba1ad..25fc51e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,14 @@ jobs: strategy: matrix: runs-on: ['macos-13', 'macos-14', 'ubuntu-24.04', 'windows-2022'] - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10', '3.11', '3.12', '3.13', 'pypy3.10'] runs-on: ${{ matrix.runs-on }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - run: sudo pipx install --global hatch - name: Install dependencies - - run: hatch test + - run: python -m pip install pytest . + name: Install testing requirements + - run: python -m pytest + name: Test From b910bf9e3dd27fa94eb89a6a7a50b370b4312eb7 Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:44:22 +0530 Subject: [PATCH 10/12] Removed unit tests; too much effort --- .github/workflows/ci.yml | 18 +----------------- tests/__init__.py | 0 tests/test_tk.py | 11 ----------- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 tests/__init__.py delete mode 100644 tests/test_tk.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25fc51e..cc5e91f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: ci on: [push, workflow_dispatch] jobs: - build: + ci: runs-on: ubuntu-22.04 container: amd64/archlinux:base steps: @@ -17,19 +17,3 @@ jobs: name: Create editable installation - run: hatch build name: Package into tarball and wheel - - test: - strategy: - matrix: - runs-on: ['macos-13', 'macos-14', 'ubuntu-24.04', 'windows-2022'] - python-version: ['3.10', '3.11', '3.12', '3.13', 'pypy3.10'] - runs-on: ${{ matrix.runs-on }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: python -m pip install pytest . - name: Install testing requirements - - run: python -m pytest - name: Test diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_tk.py b/tests/test_tk.py deleted file mode 100644 index a189f13..0000000 --- a/tests/test_tk.py +++ /dev/null @@ -1,11 +0,0 @@ -import unittest - -from ScrollableContainers import ScrollableFrameTk - - -class TestTk(unittest.TestCase): - def setUp(self): - self.scrollable_frame = ScrollableFrameTk() - - def test_trivial(self): - assert True From 0933ad53af5fdc35906b17f631c3667fc9fec91e Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:46:02 +0530 Subject: [PATCH 11/12] Restored `pyproject.toml` --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 85128a0..59a8da0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,4 +37,3 @@ system-packages = true [tool.ruff.lint.per-file-ignores] "src/ScrollableContainers/__init__.py" = ["F401", "N999"] "src/ScrollableContainers/_tk.py" = ["PLR2004"] -"tests/**" = ["S101"] From d3195c9508cf210353111a78bb53411dd5d5749e Mon Sep 17 00:00:00 2001 From: Vishal Pankaj Chandratreya <19171016+tfpf@users.noreply.github.com> Date: Mon, 10 Mar 2025 01:48:02 +0530 Subject: [PATCH 12/12] Restored part of `build.yml` --- .github/workflows/{ci.yml => build.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{ci.yml => build.yml} (96%) diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 96% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index cc5e91f..958ffbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,8 @@ -name: ci +name: build on: [push, workflow_dispatch] jobs: - ci: + build: runs-on: ubuntu-22.04 container: amd64/archlinux:base steps: