Skip to content

Commit

Permalink
Remove support for Python 3.7 and add testing for 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
MyreMylar committed Oct 11, 2023
1 parent 5ee109b commit 3005e9d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 42 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/run_tests_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions pygame_gui/core/colour_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pygame_gui/core/text/text_box_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 16 additions & 23 deletions pygame_gui/core/text/text_line_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
)

0 comments on commit 3005e9d

Please sign in to comment.