diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c93e1eb..e670b60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,12 +24,6 @@ jobs: os: ubuntu-latest # Python version testing (Linux) - - python: 3.8 - toxenv: py38 - os: ubuntu-latest - - python: 3.9 - toxenv: py39 - os: ubuntu-latest - python: "3.10" toxenv: py310 os: ubuntu-latest @@ -42,12 +36,6 @@ jobs: - python: "3.13" toxenv: py313 os: ubuntu-latest - - python: pypy-3.8 - toxenv: pypy38 - os: ubuntu-latest - - python: pypy-3.9 - toxenv: pypy39 - os: ubuntu-latest - python: pypy-3.10 toxenv: pypy310 os: ubuntu-latest diff --git a/.gitignore b/.gitignore index 4eac1e6..81ad4ac 100644 --- a/.gitignore +++ b/.gitignore @@ -86,8 +86,8 @@ target/ profile_default/ ipython_config.py -# pyenv (but we want to track our .python-version file) -# .python-version +# pyenv +.python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/.python-version b/.python-version deleted file mode 100644 index 2c07333..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.11 diff --git a/setup.py b/setup.py index 4d06e32..698d433 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def get_install_requires(): packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), long_description=read("README.rst"), install_requires=get_install_requires(), - python_requires=">=3.8", + python_requires=">=3.10", include_package_data=True, classifiers=[ "Topic :: Education", @@ -46,8 +46,6 @@ def get_install_requires(): "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", diff --git a/tilingsgui/menu.py b/tilingsgui/menu.py index 0d73723..379e582 100644 --- a/tilingsgui/menu.py +++ b/tilingsgui/menu.py @@ -23,9 +23,9 @@ class TopMenu(pyglet.event.EventDispatcher, Observer): _FONT_SIZE = 20 _TEXT_COLOR = Color.alpha_extend(Color.BLACK) _TEXT_BOX_COLOR = Color.scale_to_01(Color.WHITE) - _BACKGROUND_COLOR = Color.BLACK - _V_BTN = 118 - _CTRL_MODIFIER = 18 + _BACKGROUND_COLOR = Color.scale_to_01(Color.BLACK) + _PASTE_KEY = pyglet.window.key.V + _PASTE_MOD = pyglet.window.key.MOD_ACCEL def __init__( self, @@ -97,7 +97,7 @@ def on_key_press(self, symbol: int, modifiers: int) -> bool: bool: True if the event is consumed by the handler, false otherwise. """ if self._text_box.has_focus(): - if symbol == TopMenu._V_BTN and modifiers == TopMenu._CTRL_MODIFIER: + if symbol == TopMenu._PASTE_KEY and modifiers & TopMenu._PASTE_MOD: self._text_box.add_text(paste()) return True if symbol == pyglet.window.key.ESCAPE: diff --git a/tilingsgui/tplot.py b/tilingsgui/tplot.py index 7750e5a..3a26da4 100644 --- a/tilingsgui/tplot.py +++ b/tilingsgui/tplot.py @@ -43,6 +43,7 @@ class TPlot: _HIGHLIGHT_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01( Color.ORANGE ) + _BLACK_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(Color.BLACK) _EMPTY_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01(Color.GRAY) _SHADED_CELL_COLOR: ClassVar[Tuple[float, float, float]] = Color.scale_to_01( Color.GRAY @@ -347,7 +348,7 @@ def _draw_requirements(self, state: GuiState, mpos: Point) -> None: ): pnt = reqlist[0][0] GeoDrawer.draw_circle( - pnt.x, pnt.y, TPlot._PRETTY_POINT_SIZE, Color.BLACK + pnt.x, pnt.y, TPlot._PRETTY_POINT_SIZE, TPlot._BLACK_COLOR ) continue col = ( @@ -365,12 +366,12 @@ def _draw_requirements(self, state: GuiState, mpos: Point) -> None: def _draw_grid(self) -> None: """Draw the tiling's grid.""" t_w, t_h = self.tiling.dimensions - for i in range(t_w): + for i in range(t_w + 1): x = self._w * i / t_w - GeoDrawer.draw_line_segment(x, self._h, x, 0, Color.BLACK) - for i in range(t_h): + GeoDrawer.draw_line_segment(x, self._h, x, 0, TPlot._BLACK_COLOR) + for i in range(t_h + 1): y = self._h * i / t_h - GeoDrawer.draw_line_segment(0, y, self._w, y, Color.BLACK) + GeoDrawer.draw_line_segment(0, y, self._w, y, TPlot._BLACK_COLOR) def to_tikz(self) -> None: """Output tikz drawing.""" diff --git a/tilingsgui/widgets.py b/tilingsgui/widgets.py index 72945cd..a0b8329 100644 --- a/tilingsgui/widgets.py +++ b/tilingsgui/widgets.py @@ -25,6 +25,7 @@ def __init__(self, init_text: str, font_size: int, color: RGBA) -> None: color (Tuple[float, float, float, float]): The font color. """ + self._font_size: int = font_size self._batch: pyglet.graphics.Batch = pyglet.graphics.Batch() self._document: pyglet.text.document.UnformattedDocument = ( pyglet.text.document.UnformattedDocument(init_text) @@ -41,6 +42,7 @@ def __init__(self, init_text: str, font_size: int, color: RGBA) -> None: batch=self._batch, ) ) + self._layout.content_valign = "center" self._caret: pyglet.text.caret.Caret = pyglet.text.caret.Caret(self._layout) self._caret.visible = False @@ -54,9 +56,9 @@ def position(self, x: float, y: float, w: float, h: float) -> None: h (float): The vertical length of the component. """ self._layout.x = int(x + Text._LEFT_PAD) - self._layout.y = int(y - 15) + self._layout.y = int(y - self._font_size // 4) self._layout.width = int(w - Text._LEFT_PAD) - self._layout.height = int(h) + self._layout.height = int(h + self._font_size // 4) def set_focus(self) -> None: """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: class Button: """A clickable rectangular GUI component.""" - _BUTTON_COLOR: ClassVar[RGB] = Color.GRAY + _BUTTON_COLOR: ClassVar[RGB] = Color.scale_to_01(Color.GRAY) def __init__( self, image: str, on_click: Optional[Callable[[], None]] = None @@ -261,7 +263,7 @@ def _hit_test(self, x: float, y: float) -> bool: class ToggleButton(Button): """A button that is either on or off.""" - _TOGGLE_COLOR: ClassVar[RGB] = Color.DARK_OLIVE_GREEN + _TOGGLE_COLOR: ClassVar[RGB] = Color.scale_to_01(Color.DARK_OLIVE_GREEN) def __init__( self, diff --git a/tox.ini b/tox.ini index d2fb7a9..aa99df1 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,8 @@ [tox] envlist = flake8, mypy, pylint, black - py{38,39,310,311,312,313}, - pypy{38,39,310} + py{310,311,312,313}, + pypy{310} [default] basepython=python3.11 @@ -15,14 +15,10 @@ basepython=python3.11 [testenv] description = run test basepython = - py38: python3.8 - py39: python3.9 py310: python3.10 py311: python3.11 py312: python3.12 py313: python3.13 - pypy38: pypy3.8 - pypy39: pypy3.9 pypy310: pypy3.10 deps = setuptools