Skip to content

Commit 87cb280

Browse files
authored
Normalize colors, fix UI input, bump Python to 3.10 (#47)
* Normalize colors, fix UI input, bump Python to 3.10 Update UI components and project metadata: - Bump python_requires to >=3.10 and remove 3.8/3.9 classifiers in setup.py. - Stop ignoring .python-version in .gitignore (and remove the file) to track pyenv version. - Normalize color usage by scaling Color values to 0..1 and introduce TPlot._BLACK_COLOR; use it when drawing points and grid. - Fix grid drawing ranges to include boundary lines (range + 1). - Improve paste handling in TopMenu by using pyglet.key constants for the paste key and accelerator modifier. - Adjust Text widget sizing: store font size, center content vertically, and tweak layout y/height calculations. - Scale Button and ToggleButton colors to normalized RGB. These changes improve visual consistency, correct rendering and input behavior, and update supported Python versions. * Drop Python 3.8/3.9 and PyPy 3.8/3.9 from CI Update GitHub Actions and tox configuration to remove older interpreters. Removed Python 3.8 and 3.9 entries (and tox envs py38/py39) and removed PyPy 3.8/3.9 entries; retained CPython 3.10–3.13 and PyPy 3.10. Adjusted tox envlist and testenv basepython mappings to match the new test matrix (.github/workflows/test.yml and tox.ini).
1 parent 4e09800 commit 87cb280

8 files changed

Lines changed: 21 additions & 37 deletions

File tree

.github/workflows/test.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ jobs:
2424
os: ubuntu-latest
2525

2626
# Python version testing (Linux)
27-
- python: 3.8
28-
toxenv: py38
29-
os: ubuntu-latest
30-
- python: 3.9
31-
toxenv: py39
32-
os: ubuntu-latest
3327
- python: "3.10"
3428
toxenv: py310
3529
os: ubuntu-latest
@@ -42,12 +36,6 @@ jobs:
4236
- python: "3.13"
4337
toxenv: py313
4438
os: ubuntu-latest
45-
- python: pypy-3.8
46-
toxenv: pypy38
47-
os: ubuntu-latest
48-
- python: pypy-3.9
49-
toxenv: pypy39
50-
os: ubuntu-latest
5139
- python: pypy-3.10
5240
toxenv: pypy310
5341
os: ubuntu-latest

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ target/
8686
profile_default/
8787
ipython_config.py
8888

89-
# pyenv (but we want to track our .python-version file)
90-
# .python-version
89+
# pyenv
90+
.python-version
9191

9292
# pipenv
9393
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_install_requires():
3737
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
3838
long_description=read("README.rst"),
3939
install_requires=get_install_requires(),
40-
python_requires=">=3.8",
40+
python_requires=">=3.10",
4141
include_package_data=True,
4242
classifiers=[
4343
"Topic :: Education",
@@ -46,8 +46,6 @@ def get_install_requires():
4646
"Intended Audience :: Science/Research",
4747
"License :: OSI Approved :: BSD License",
4848
"Programming Language :: Python :: 3",
49-
"Programming Language :: Python :: 3.8",
50-
"Programming Language :: Python :: 3.9",
5149
"Programming Language :: Python :: 3.10",
5250
"Programming Language :: Python :: 3.11",
5351
"Programming Language :: Python :: 3.12",

tilingsgui/menu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class TopMenu(pyglet.event.EventDispatcher, Observer):
2323
_FONT_SIZE = 20
2424
_TEXT_COLOR = Color.alpha_extend(Color.BLACK)
2525
_TEXT_BOX_COLOR = Color.scale_to_01(Color.WHITE)
26-
_BACKGROUND_COLOR = Color.BLACK
27-
_V_BTN = 118
28-
_CTRL_MODIFIER = 18
26+
_BACKGROUND_COLOR = Color.scale_to_01(Color.BLACK)
27+
_PASTE_KEY = pyglet.window.key.V
28+
_PASTE_MOD = pyglet.window.key.MOD_ACCEL
2929

3030
def __init__(
3131
self,
@@ -97,7 +97,7 @@ def on_key_press(self, symbol: int, modifiers: int) -> bool:
9797
bool: True if the event is consumed by the handler, false otherwise.
9898
"""
9999
if self._text_box.has_focus():
100-
if symbol == TopMenu._V_BTN and modifiers == TopMenu._CTRL_MODIFIER:
100+
if symbol == TopMenu._PASTE_KEY and modifiers & TopMenu._PASTE_MOD:
101101
self._text_box.add_text(paste())
102102
return True
103103
if symbol == pyglet.window.key.ESCAPE:

tilingsgui/tplot.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class TPlot:
4343
_HIGHLIGHT_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(
4444
Color.ORANGE
4545
)
46+
_BLACK_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(Color.BLACK)
4647
_EMPTY_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(Color.GRAY)
4748
_SHADED_CELL_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(
4849
Color.GRAY
@@ -347,7 +348,7 @@ def _draw_requirements(self, state: GuiState, mpos: Point) -> None:
347348
):
348349
pnt = reqlist[0][0]
349350
GeoDrawer.draw_circle(
350-
pnt.x, pnt.y, TPlot._PRETTY_POINT_SIZE, Color.BLACK
351+
pnt.x, pnt.y, TPlot._PRETTY_POINT_SIZE, TPlot._BLACK_COLOR
351352
)
352353
continue
353354
col = (
@@ -365,12 +366,12 @@ def _draw_requirements(self, state: GuiState, mpos: Point) -> None:
365366
def _draw_grid(self) -> None:
366367
"""Draw the tiling's grid."""
367368
t_w, t_h = self.tiling.dimensions
368-
for i in range(t_w):
369+
for i in range(t_w + 1):
369370
x = self._w * i / t_w
370-
GeoDrawer.draw_line_segment(x, self._h, x, 0, Color.BLACK)
371-
for i in range(t_h):
371+
GeoDrawer.draw_line_segment(x, self._h, x, 0, TPlot._BLACK_COLOR)
372+
for i in range(t_h + 1):
372373
y = self._h * i / t_h
373-
GeoDrawer.draw_line_segment(0, y, self._w, y, Color.BLACK)
374+
GeoDrawer.draw_line_segment(0, y, self._w, y, TPlot._BLACK_COLOR)
374375

375376
def to_tikz(self) -> None:
376377
"""Output tikz drawing."""

tilingsgui/widgets.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, init_text: str, font_size: int, color: RGBA) -> None:
2525
color (Tuple[float, float, float, float]): The font color.
2626
"""
2727

28+
self._font_size: int = font_size
2829
self._batch: pyglet.graphics.Batch = pyglet.graphics.Batch()
2930
self._document: pyglet.text.document.UnformattedDocument = (
3031
pyglet.text.document.UnformattedDocument(init_text)
@@ -41,6 +42,7 @@ def __init__(self, init_text: str, font_size: int, color: RGBA) -> None:
4142
batch=self._batch,
4243
)
4344
)
45+
self._layout.content_valign = "center"
4446
self._caret: pyglet.text.caret.Caret = pyglet.text.caret.Caret(self._layout)
4547
self._caret.visible = False
4648

@@ -54,9 +56,9 @@ def position(self, x: float, y: float, w: float, h: float) -> None:
5456
h (float): The vertical length of the component.
5557
"""
5658
self._layout.x = int(x + Text._LEFT_PAD)
57-
self._layout.y = int(y - 15)
59+
self._layout.y = int(y - self._font_size // 4)
5860
self._layout.width = int(w - Text._LEFT_PAD)
59-
self._layout.height = int(h)
61+
self._layout.height = int(h + self._font_size // 4)
6062

6163
def set_focus(self) -> None:
6264
"""Set focus on the input text. This is needed to write to it."""
@@ -168,7 +170,7 @@ def hit_test(self, x: float, y: float) -> bool:
168170
class Button:
169171
"""A clickable rectangular GUI component."""
170172

171-
_BUTTON_COLOR: ClassVar[RGB] = Color.GRAY
173+
_BUTTON_COLOR: ClassVar[RGB] = Color.scale_to_01(Color.GRAY)
172174

173175
def __init__(
174176
self, image: str, on_click: Optional[Callable[[], None]] = None
@@ -261,7 +263,7 @@ def _hit_test(self, x: float, y: float) -> bool:
261263
class ToggleButton(Button):
262264
"""A button that is either on or off."""
263265

264-
_TOGGLE_COLOR: ClassVar[RGB] = Color.DARK_OLIVE_GREEN
266+
_TOGGLE_COLOR: ClassVar[RGB] = Color.scale_to_01(Color.DARK_OLIVE_GREEN)
265267

266268
def __init__(
267269
self,

tox.ini

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66
[tox]
77
envlist =
88
flake8, mypy, pylint, black
9-
py{38,39,310,311,312,313},
10-
pypy{38,39,310}
9+
py{310,311,312,313},
10+
pypy{310}
1111

1212
[default]
1313
basepython=python3.11
1414

1515
[testenv]
1616
description = run test
1717
basepython =
18-
py38: python3.8
19-
py39: python3.9
2018
py310: python3.10
2119
py311: python3.11
2220
py312: python3.12
2321
py313: python3.13
24-
pypy38: pypy3.8
25-
pypy39: pypy3.9
2622
pypy310: pypy3.10
2723
deps =
2824
setuptools

0 commit comments

Comments
 (0)