From 9c633515c93ca48341ae2b595c04407fc69f990e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:40:17 +0000 Subject: [PATCH 1/2] Initial plan From e00206e31459c5d6bef8065057b410d491479175 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:50:15 +0000 Subject: [PATCH 2/2] Update PygameUIKit to support latest Python version (3.12) Co-authored-by: Times0 <45049767+Times0@users.noreply.github.com> --- .github/workflows/publish-to-pypi.yml | 6 +++--- pyproject.toml | 5 ++++- src/PygameUIKit/barchart.py | 2 +- src/PygameUIKit/combobox.py | 3 ++- src/PygameUIKit/text_input.py | 4 ++-- src/PygameUIKit/utilis.py | 4 +--- src/demo.py | 6 +++--- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index c695e9f..ac54b5e 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -11,12 +11,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.11 + python-version: "3.12" - name: Install dependencies run: | diff --git a/pyproject.toml b/pyproject.toml index 913e37b..276b018 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,12 @@ authors = [ ] description = "A UIKit for Pygame" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.10" classifiers = [ "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] diff --git a/src/PygameUIKit/barchart.py b/src/PygameUIKit/barchart.py index e2c70a1..5f27fb9 100644 --- a/src/PygameUIKit/barchart.py +++ b/src/PygameUIKit/barchart.py @@ -18,7 +18,7 @@ def color_from_float(colors): class BarChart(EasyObject): def __init__(self, values: list[int], - labels: list[str] = None, + labels: list[str] | None = None, max_value=None, ui_group=None, font=pg.font.SysFont("Arial", 15), diff --git a/src/PygameUIKit/combobox.py b/src/PygameUIKit/combobox.py index 144f7b8..f208c8a 100644 --- a/src/PygameUIKit/combobox.py +++ b/src/PygameUIKit/combobox.py @@ -1,4 +1,5 @@ import os +from collections.abc import Callable from pygame import Color import pygame as pg from .label import DEFAULT_FONT, Label @@ -23,7 +24,7 @@ def __init__(self, elements: list[str], ui_group=None, font=DEFAULT_FONT, font_c self.hovered_index = self.selected_index self.is_open = False self._labels: list[Label] = [] - self.actions: dict[int, callable] = {} + self.actions: dict[int, Callable] = {} self.img_arrow_down = load_image(os.path.join(cwd, "assets", "combo_box_arrow.png"), (20, 20)) self.img_arrow_up = pg.transform.rotate(self.img_arrow_down.copy(), 180) diff --git a/src/PygameUIKit/text_input.py b/src/PygameUIKit/text_input.py index 21c975f..e6b60ce 100644 --- a/src/PygameUIKit/text_input.py +++ b/src/PygameUIKit/text_input.py @@ -21,8 +21,8 @@ def is_char(unicode): class TextInput(EasyObject): def __init__(self, *, text="", - font: pg.font.Font = None, - fixed_width: int = None, + font: pg.font.Font | None = None, + fixed_width: int | None = None, font_color=pg.Color('black'), border_radius=0, placeholder="", diff --git a/src/PygameUIKit/utilis.py b/src/PygameUIKit/utilis.py index d2ee4a0..73151ff 100644 --- a/src/PygameUIKit/utilis.py +++ b/src/PygameUIKit/utilis.py @@ -1,5 +1,3 @@ -from typing import Union - import pygame as pg from pygame import Color @@ -28,7 +26,7 @@ def draw_transparent_rect_with_border_radius(screen, color, rect, border_radius, screen.blit(surf, rect) -def best_contrast_color(rgb_color: Union[Color, tuple]): +def best_contrast_color(rgb_color: Color | tuple): if isinstance(rgb_color, Color): rgb_color = rgb_color.r, rgb_color.g, rgb_color.b r, g, b = rgb_color diff --git a/src/demo.py b/src/demo.py index 7c8d0d8..7f53027 100644 --- a/src/demo.py +++ b/src/demo.py @@ -4,9 +4,9 @@ import pygame from pygame import Color -from src.PygameUIKit import Group -from src.PygameUIKit import text_input, button, slider, combobox -from src.PygameUIKit.barchart import BarChart +from PygameUIKit import Group +from PygameUIKit import text_input, button, slider, combobox +from PygameUIKit.barchart import BarChart # #