Skip to content

Commit 589e77e

Browse files
authored
Switch from Setuptools to Hatch. (Attempt 2.) (#3)
* Changed `pyproject.toml` settings to use Hatch. * Build failed because of no Setuptools. Added. * Removed Setuptools dependency. * It is not needed. Clang was needed. * Added build workflow. * Verbose logging in GitHub Actions workflow. * Renamed 'build' workflow to 'install'. * Building means creating an installable package * This workflow installs the package in development mode. * Added lint workflow. * Removed `Makefile` since Hatch can build and publish. * Fixed some lints. * Lint ignore rules for `__init__.py`. * Fixed more lints. * Fixed invalid module names. * Except the main module, `ScrollableContainers`. * I have already registered it on PyPI, so this invalid name will have to stay. * Ran `hatch fmt`. * Reduced maximum width of docstrings to 79 characters. * `hatch fmt` indented them outwards without wrapping them. * Added build workflow. * Reduced verbosity of build and format workflows. * Changed version to alpha 0. * Since I have made no releases with this major version number yet, it is okay to change it to a pre-release version. * I plan to use alpha releases to see how it looks on PyPI rather than using TestPyPI.
1 parent fac411f commit 589e77e

16 files changed

+274
-233
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: build
2+
on: [push, workflow_dispatch]
3+
4+
jobs:
5+
build:
6+
name: build on ubuntu-22.04
7+
runs-on: ubuntu-22.04
8+
steps:
9+
- uses: actions/checkout@v4
10+
- run: pipx install hatch
11+
- run: hatch build

.github/workflows/install.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: install
2+
on: [push, workflow_dispatch]
3+
4+
jobs:
5+
install:
6+
name: install on ubuntu-22.04
7+
runs-on: ubuntu-22.04
8+
steps:
9+
- uses: actions/checkout@v4
10+
- run: pipx install hatch
11+
- run: sudo apt install libgtk-3-dev
12+
- run: hatch -vv env create dev

.github/workflows/lint.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: lint
2+
on: [push, workflow_dispatch]
3+
4+
jobs:
5+
lint:
6+
name: lint on ubuntu-22.04
7+
runs-on: ubuntu-22.04
8+
steps:
9+
- uses: actions/checkout@v4
10+
- run: pipx install hatch
11+
- run: hatch fmt --check

Makefile

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Scrollable containers are currently available for the following GUI toolkits.
2020
to: the Tcl Core Team, the Python Software Foundation, the wxWidgets Team, the wxPython Team, the Qt Company and
2121
Riverbank Computing.**
2222

23+
[![lint](https://github.com/tfpf/ScrollableContainers/actions/workflows/lint.yml/badge.svg)](https://github.com/tfpf/ScrollableContainers/actions/workflows/lint.yml)
24+
[![install](https://github.com/tfpf/ScrollableContainers/actions/workflows/install.yml/badge.svg)](https://github.com/tfpf/ScrollableContainers/actions/workflows/install.yml)
25+
[![build](https://github.com/tfpf/ScrollableContainers/actions/workflows/build.yml/badge.svg)](https://github.com/tfpf/ScrollableContainers/actions/workflows/build.yml)
26+
2327
# Tkinter
2428
`ScrollableContainers.ScrollableFrameTk`: a comprehensive implementation of a scrollable frame, and the flagship class
2529
of this project. (I wrote the other classes just for completeness.)
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
#! /usr/bin/env python3
22

33
import itertools
4+
45
from PyQt5.QtCore import QSize
56
from PyQt5.QtWidgets import QApplication, QGridLayout, QLabel, QMainWindow, QVBoxLayout
6-
77
from ScrollableContainers import ScrollableAreaQt5
88

99

1010
class ExamplesScrollableAreaQt5:
11-
1211
def __init__(self):
1312
self.grid_of_widgets(QMainWindow())
1413
self.single_widget(QMainWindow())
1514

1615
def grid_of_widgets(self, window):
1716
self.win1 = window
18-
window.setWindowTitle('`ScrollableAreaQt5` demo')
17+
window.setWindowTitle("`ScrollableAreaQt5` demo")
1918

2019
# Create a scrollable area.
2120
scrollable_area = ScrollableAreaQt5()
@@ -24,29 +23,29 @@ def grid_of_widgets(self, window):
2423
# the scrollable area itself.
2524
dim = 10
2625
grid_layout = QGridLayout(scrollable_area.area)
27-
for (i, j) in itertools.product(range(dim), repeat=2):
28-
label = QLabel(text=f'Label\n({i}, {j})')
26+
for i, j in itertools.product(range(dim), repeat=2):
27+
label = QLabel(text=f"Label\n({i}, {j})")
2928
grid_layout.addWidget(label, i, j)
3029

3130
window.setCentralWidget(scrollable_area)
3231
window.show()
3332

3433
def single_widget(self, window):
3534
self.win2 = window
36-
window.setWindowTitle('`ScrollableAreaQt5` demo')
35+
window.setWindowTitle("`ScrollableAreaQt5` demo")
3736
window.resize(QSize(600, 200))
3837

3938
scrollable_area = ScrollableAreaQt5()
4039

4140
vbox = QVBoxLayout(scrollable_area.area)
42-
label = QLabel(text='big window, small label')
41+
label = QLabel(text="big window, small label")
4342
vbox.addWidget(label)
4443

4544
window.setCentralWidget(scrollable_area)
4645
window.show()
4746

4847

49-
if __name__ == '__main__':
48+
if __name__ == "__main__":
5049
app = QApplication([])
5150
examples = ExamplesScrollableAreaQt5()
5251
app.exec()
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
#! /usr/bin/env python3
22

33
import itertools
4+
45
from PyQt6.QtCore import QSize
56
from PyQt6.QtWidgets import QApplication, QGridLayout, QLabel, QMainWindow, QVBoxLayout
6-
77
from ScrollableContainers import ScrollableAreaQt6
88

99

1010
class ExamplesScrollableAreaQt6:
11-
1211
def __init__(self):
1312
self.grid_of_widgets(QMainWindow())
1413
self.single_widget(QMainWindow())
1514

1615
def grid_of_widgets(self, window):
1716
self.win1 = window
18-
window.setWindowTitle('`ScrollableAreaQt6` demo')
17+
window.setWindowTitle("`ScrollableAreaQt6` demo")
1918

2019
# Create a scrollable area.
2120
scrollable_area = ScrollableAreaQt6()
@@ -24,29 +23,29 @@ def grid_of_widgets(self, window):
2423
# the scrollable area itself.
2524
dim = 10
2625
grid_layout = QGridLayout(scrollable_area.area)
27-
for (i, j) in itertools.product(range(dim), repeat=2):
28-
label = QLabel(text=f'Label\n({i}, {j})')
26+
for i, j in itertools.product(range(dim), repeat=2):
27+
label = QLabel(text=f"Label\n({i}, {j})")
2928
grid_layout.addWidget(label, i, j)
3029

3130
window.setCentralWidget(scrollable_area)
3231
window.show()
3332

3433
def single_widget(self, window):
3534
self.win2 = window
36-
window.setWindowTitle('`ScrollableAreaQt6` demo')
35+
window.setWindowTitle("`ScrollableAreaQt6` demo")
3736
window.resize(QSize(600, 200))
3837

3938
scrollable_area = ScrollableAreaQt6()
4039

4140
vbox = QVBoxLayout(scrollable_area.area)
42-
label = QLabel(text='big window, small label')
41+
label = QLabel(text="big window, small label")
4342
vbox.addWidget(label)
4443

4544
window.setCentralWidget(scrollable_area)
4645
window.show()
4746

4847

49-
if __name__ == '__main__':
48+
if __name__ == "__main__":
5049
app = QApplication([])
5150
examples = ExamplesScrollableAreaQt6()
5251
app.exec()

examples/examples_ScrollableFrameTk.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,43 @@
22

33
import itertools
44
import tkinter as tk
5-
import tkinter.ttk as ttk
5+
from tkinter import ttk
66

77
from ScrollableContainers import ScrollableFrameTk
88

99

1010
class ExamplesScrollableFrameTk:
11-
1211
def __init__(self):
1312
self.grid_of_widgets(tk.Tk())
1413
self.single_widget(tk.Toplevel())
1514

1615
def grid_of_widgets(self, window):
17-
window.title('`ScrollableFrameTk` Demo')
16+
window.title("`ScrollableFrameTk` Demo")
1817

1918
# Create a scrollable frame.
2019
scrollable_frame = ScrollableFrameTk(window)
2120

2221
# Add widgets to the `frame` attribute of the scrollable frame, not to
2322
# the scrollable frame itself.
2423
dim = 10
25-
for (i, j) in itertools.product(range(dim), repeat=2):
26-
label = ttk.Label(scrollable_frame.frame, text=f'Label\n({i}, {j})')
24+
for i, j in itertools.product(range(dim), repeat=2):
25+
label = ttk.Label(scrollable_frame.frame, text=f"Label\n({i}, {j})")
2726
label.grid(row=i, column=j, padx=10, pady=10)
2827

2928
scrollable_frame.pack(expand=True, fill=tk.BOTH)
3029

3130
def single_widget(self, window):
32-
window.geometry('600x200+50+50')
33-
window.title('`ScrollableFrameTk` Demo')
31+
window.geometry("600x200+50+50")
32+
window.title("`ScrollableFrameTk` Demo")
3433

3534
scrollable_frame = ScrollableFrameTk(window)
3635

37-
label = ttk.Label(scrollable_frame.frame, text='big window, small label')
36+
label = ttk.Label(scrollable_frame.frame, text="big window, small label")
3837
label.pack()
3938

4039
scrollable_frame.pack(expand=True, fill=tk.BOTH)
4140

4241

43-
if __name__ == '__main__':
42+
if __name__ == "__main__":
4443
examples = ExamplesScrollableFrameTk()
4544
tk.mainloop()
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#! /usr/bin/env python3
22

33
import itertools
4-
import wx
54

5+
import wx
66
from ScrollableContainers import ScrollablePanelWx
77

88

99
class ExamplesScrollablePanelWx:
10-
1110
def __init__(self):
1211
self.grid_of_widgets(wx.Frame(None))
1312
self.single_widget(wx.Frame(None))
1413

1514
def grid_of_widgets(self, window):
16-
window.SetTitle('`ScrollablePanelWx` Demo')
15+
window.SetTitle("`ScrollablePanelWx` Demo")
1716

1817
# Create a scrollable panel.
1918
scrollable_panel = ScrollablePanelWx(window)
@@ -22,27 +21,27 @@ def grid_of_widgets(self, window):
2221
# the scrollable panel itself.
2322
dim = 10
2423
grid_sizer = wx.GridSizer(dim, dim, 20, 20)
25-
for (i, j) in itertools.product(range(dim), repeat=2):
26-
text = wx.StaticText(scrollable_panel.panel, label=f'Label\n({i}, {j})')
24+
for i, j in itertools.product(range(dim), repeat=2):
25+
text = wx.StaticText(scrollable_panel.panel, label=f"Label\n({i}, {j})")
2726
grid_sizer.Add(text)
2827

2928
scrollable_panel.panel.SetSizer(grid_sizer)
3029
scrollable_panel.SetupScrolling()
3130
window.Show()
3231

3332
def single_widget(self, window):
34-
window.SetTitle('`ScrollablePanelWx` Demo')
33+
window.SetTitle("`ScrollablePanelWx` Demo")
3534
window.SetSize(600, 200)
3635

3736
scrollable_panel = ScrollablePanelWx(window)
3837

39-
wx.StaticText(scrollable_panel.panel, label='big window, small label')
38+
wx.StaticText(scrollable_panel.panel, label="big window, small label")
4039

4140
scrollable_panel.SetupScrolling()
4241
window.Show()
4342

4443

45-
if __name__ == '__main__':
44+
if __name__ == "__main__":
4645
app = wx.App()
4746
examples = ExamplesScrollablePanelWx()
4847
app.MainLoop()

pyproject.toml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "ScrollableContainers"
7-
version = "2.0.1"
7+
version = "2.0.1a0"
88
authors = [
9-
{ name="Vishal Pankaj Chandratreya" },
9+
{ name = "Vishal Pankaj Chandratreya" },
1010
]
1111
description = "Scrollable containers for Tkinter, wxPython, PyQt5 and PyQt6"
1212
readme = "README.md"
@@ -17,6 +17,22 @@ classifiers = [
1717
"Operating System :: OS Independent",
1818
]
1919

20+
[project.optional-dependencies]
21+
qt5 = ["PyQt5"]
22+
qt6 = ["PyQt6"]
23+
wx = ["wxPython"]
24+
2025
[project.urls]
2126
"Homepage" = "https://github.com/tfpf/ScrollableContainers"
2227
"Bug Tracker" = "https://github.com/tfpf/ScrollableContainers/issues"
28+
29+
[tool.hatch.envs.dev]
30+
features = [
31+
"qt5",
32+
"qt6",
33+
"wx",
34+
]
35+
36+
[tool.ruff.lint.per-file-ignores]
37+
"src/ScrollableContainers/__init__.py" = ["F401", "N999"]
38+
"src/ScrollableContainers/_tk.py" = ["PLR2004"]

0 commit comments

Comments
 (0)