diff --git a/.github/workflows/run_tests_ci.yml b/.github/workflows/run_tests_ci.yml index 498a5e10..7ef1f45a 100644 --- a/.github/workflows/run_tests_ci.yml +++ b/.github/workflows/run_tests_ci.yml @@ -8,8 +8,8 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - pygame-ce-version: ['2.1.4', '2.2.1'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + pygame-ce-version: ['2.2.1', '2.3.2'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -47,8 +47,8 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [ '3.11' ] - pygame-ce-version: [ '2.1.4', '2.2.1' ] + python-version: [ '3.12' ] + pygame-ce-version: [ '2.2.1', '2.3.2' ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -83,8 +83,8 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [ '3.11' ] - pygame-ce-version: [ '2.1.4', '2.2.1' ] + python-version: [ '3.12' ] + pygame-ce-version: [ '2.2.1', '2.3.2' ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/README.md b/README.md index 7c759e22..850f25a5 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ A GUI system for pygame CE. - [Examples](https://github.com/MyreMylar/pygame_gui_examples) - [PyPi](https://pypi.org/project/pygame-gui/) -[![pypi](https://badge.fury.io/py/pygame-gui.svg)](https://pypi.python.org/pypi/pygame-gui) [![Documentation Status](https://readthedocs.org/projects/pygame-gui/badge/?version=latest)](https://pygame-gui.readthedocs.io/en/latest/?badge=latest) [![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-360/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Master](https://travis-ci.com/MyreMylar/pygame_gui.svg?branch=master)](https://travis-ci.com/MyreMylar/pygame_gui) [![codecov](https://codecov.io/gh/MyreMylar/pygame_gui/branch/main/graph/badge.svg?token=zZhkvhgTki)](https://codecov.io/gh/MyreMylar/pygame_gui) [![Downloads](https://pepy.tech/badge/pygame-gui)](https://pepy.tech/project/pygame-gui) +[![pypi](https://badge.fury.io/py/pygame-gui.svg)](https://pypi.python.org/pypi/pygame-gui) [![Documentation Status](https://readthedocs.org/projects/pygame-gui/badge/?version=latest)](https://pygame-gui.readthedocs.io/en/latest/?badge=latest) [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Master](https://travis-ci.com/MyreMylar/pygame_gui.svg?branch=master)](https://travis-ci.com/MyreMylar/pygame_gui) [![codecov](https://codecov.io/gh/MyreMylar/pygame_gui/branch/main/graph/badge.svg?token=zZhkvhgTki)](https://codecov.io/gh/MyreMylar/pygame_gui) [![Downloads](https://pepy.tech/badge/pygame-gui)](https://pepy.tech/project/pygame-gui) ## Requirements - - Python 3.7+ + - Python 3.8+ - Pygame Community Edition 2.1.4+ - python-i18n (does localization to different languages) diff --git a/pygame_gui/core/colour_parser.py b/pygame_gui/core/colour_parser.py index 8f707e4b..3cfdf146 100644 --- a/pygame_gui/core/colour_parser.py +++ b/pygame_gui/core/colour_parser.py @@ -28,12 +28,8 @@ """ import pygame -from typing import Callable, Union, Iterable, TypeVar, Optional, List, Tuple, Set, Dict -# for Python 3.7 compatibility as TypedDict introduced in 3.8 -try: - from typing import TypedDict -except ImportError: - from typing_extensions import TypedDict +from typing import Callable, Union, Iterable, TypeVar, Optional, List, Tuple, Set, Dict, TypedDict + import enum from pygame_gui.core.colour_gradient import ColourGradient from pygame_gui.core.utility import premul_col diff --git a/pygame_gui/core/text/text_box_layout.py b/pygame_gui/core/text/text_box_layout.py index 877bfa52..c13ed32f 100644 --- a/pygame_gui/core/text/text_box_layout.py +++ b/pygame_gui/core/text/text_box_layout.py @@ -366,6 +366,8 @@ def finalise_to_surf(self, surface: Surface): else: for row in self.layout_rows: row.finalise(surface) + # pygame.draw.rect(surface, pygame.Color("blue"), row, 1) + # print("row height:", row.height) for floating_rect in self.floating_rects: floating_rect.finalise(surface, self.view_rect, 0, 0, 0) diff --git a/pygame_gui/core/text/text_line_chunk.py b/pygame_gui/core/text/text_line_chunk.py index 3de8f0c2..b5a59a8f 100644 --- a/pygame_gui/core/text/text_line_chunk.py +++ b/pygame_gui/core/text/text_line_chunk.py @@ -37,7 +37,8 @@ def __init__(self, text: str, max_dimensions: Optional[Tuple[int, int]] = None, effect_id: Optional[str] = None): self.text_shadow_data = text_shadow_data - text_height, text_rect, text_width = self._handle_dimensions(font, max_dimensions, text) + self.max_dimensions = max_dimensions + text_height, text_rect, text_width = self._handle_dimensions(font, text) super().__init__((text_width, text_height), can_split=True) self.text = text @@ -56,7 +57,6 @@ def __init__(self, text: str, self.using_default_text_shadow_colour = self.text_shadow_data[4] self.shadow_colour = self.text_shadow_data[3] - self.max_dimensions = max_dimensions self.y_origin = text_rect.y self.font_y_padding = self._calc_font_padding() @@ -97,7 +97,16 @@ def __init__(self, text: str, def __repr__(self): return "< '" + self.text + "' " + super().__repr__() + " >" - def _handle_dimensions(self, font, max_dimensions, text): + def _clamp_dimensions_to_maximums(self, text_width, text_height): + if self.max_dimensions is not None: + if not (self.max_dimensions[0] == -1 or self.max_dimensions[1] == -1): + # we don't have dynamic maximum dimensions so use maximum dimensions for both + text_width = min(self.max_dimensions[0], text_width) + text_height = min(self.max_dimensions[1], text_height) + + return text_width, text_height + + def _handle_dimensions(self, font, text): if len(text) == 0: text_rect = font.get_rect('A') else: @@ -108,11 +117,7 @@ def _handle_dimensions(self, font, max_dimensions, text): text_shadow_width = self.text_shadow_data[0] text_width = self._text_render_width(text, font) + (2 * text_shadow_width) text_height = text_rect.height - if max_dimensions is not None: - if not (max_dimensions[0] == -1 or max_dimensions[1] == -1): - # we don't have dynamic maximum dimensions so use maximum dimensions for both - text_width = min(max_dimensions[0], text_width) - text_height = min(max_dimensions[1], text_height) + text_width, text_height = self._clamp_dimensions_to_maximums(text_width, text_height) return text_height, text_rect, text_width def _calc_font_padding(self): @@ -566,11 +571,7 @@ def insert_text(self, input_text: str, index: int): text_rect = self.font.get_rect(self.text) text_width = self._text_render_width(self.text, self.font) text_height = text_rect.height - if self.max_dimensions is not None: - if not (self.max_dimensions[0] == -1 or self.max_dimensions[1] == -1): - # we don't have dynamic maximum dimensions so use maximum dimensions for both - text_width = min(self.max_dimensions[0], text_width) - text_height = min(self.max_dimensions[1], text_height) + text_width, text_height = self._clamp_dimensions_to_maximums(text_width, text_height) self.size = (text_width, text_height) # noqa pylint: disable=attribute-defined-outside-init; pylint getting confused @@ -591,11 +592,7 @@ def delete_letter_at_index(self, index): text_rect = self.font.get_rect(self.text) text_width = self._text_render_width(self.text, self.font) text_height = text_rect.height - if self.max_dimensions is not None: - if not (self.max_dimensions[0] == -1 or self.max_dimensions[1] == -1): - # we don't have dynamic maximum dimensions so use maximum dimensions for both - text_width = min(self.max_dimensions[0], text_width) - text_height = min(self.max_dimensions[1], text_height) + text_width, text_height = self._clamp_dimensions_to_maximums(text_width, text_height) self.size = (text_width, text_height) # noqa pylint: disable=attribute-defined-outside-init; pylint getting confused @@ -616,11 +613,7 @@ def backspace_letter_at_index(self, index): text_rect = self.font.get_rect(self.text) text_width = self._text_render_width(self.text, self.font) text_height = text_rect.height - if self.max_dimensions is not None: - if self.max_dimensions[0] != -1: - text_width = min(self.max_dimensions[0], text_width) - if self.max_dimensions[1] != -1: - text_height = min(self.max_dimensions[1], text_height) + text_width, text_height = self._clamp_dimensions_to_maximums(text_width, text_height) self.size = (text_width, text_height) # noqa pylint: disable=attribute-defined-outside-init; pylint getting confused diff --git a/readthedocs.yaml b/readthedocs.yaml index 8824b0b9..46337527 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -15,6 +15,6 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 + version: 3.8 install: - requirements: docs/requirements.txt \ No newline at end of file diff --git a/setup.py b/setup.py index 192b64ed..173da207 100644 --- a/setup.py +++ b/setup.py @@ -27,22 +27,21 @@ 'pygame_gui.data', 'pygame_gui.data.translations'], zip_safe=False, - python_requires='>=3.7', + python_requires='>=3.8', setup_requires=[], install_requires=['pygame-ce>=2.1.4', 'python-i18n>=0.3.9', - 'importlib_resources>1.3; python_version < "3.9"', - 'typing-extensions; python_version < "3.8"'], + 'importlib_resources>1.3; python_version < "3.9"'], include_package_data=True, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Topic :: Software Development :: Build Tools', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.7', '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', ], )