From 0579aa140d1385b5930ac43a4235eecb3f9cdfe0 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Thu, 18 Jul 2024 23:30:42 -0600 Subject: [PATCH] Mods --- cromulant/ants.py | 6 ++++-- cromulant/game.py | 19 +++++++++++++------ cromulant/utils.py | 2 +- cromulant/window.py | 15 +++++++-------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/cromulant/ants.py b/cromulant/ants.py index 57de992..217e837 100644 --- a/cromulant/ants.py +++ b/cromulant/ants.py @@ -37,7 +37,9 @@ class Ant: self.status = data["status"] self.hits = data["hits"] self.triumph = data["triumph"] - self.color = tuple(data["color"]) + + c = data["color"] + self.color = (c[0], c[1], c[2]) def get_name(self) -> str: return self.name or "Nameless" @@ -136,4 +138,4 @@ class Ants: for obj in objs: ant = Ant() ant.from_dict(obj) - Ants.ants.append(ant) \ No newline at end of file + Ants.ants.append(ant) diff --git a/cromulant/game.py b/cromulant/game.py index ba9b8f6..e6d3526 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -4,7 +4,7 @@ import random from pathlib import Path from PySide6.QtCore import Qt # type: ignore -from PySide6.QtWidgets import QHBoxLayout +from PySide6.QtWidgets import QHBoxLayout # type: ignore from PySide6.QtWidgets import QVBoxLayout from PySide6.QtWidgets import QLabel from PySide6.QtGui import QPixmap # type: ignore @@ -62,7 +62,7 @@ class Game: @staticmethod def make_right_container(title: str, message: str) -> QVBoxLayout: container = QVBoxLayout() - container.setAlignment(Qt.AlignTop) + container.setAlignment(Qt.AlignmentFlag.AlignTop) title_label = QLabel(title) title_label.setStyleSheet("font-weight: bold;") message_label = QLabel(message) @@ -76,13 +76,20 @@ class Game: pixmap = QPixmap(str(image_path)) scaled_pixmap = pixmap.scaled( - Config.image_size, pixmap.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation + Config.image_size, + pixmap.height(), + Qt.AspectRatioMode.KeepAspectRatio, + Qt.TransformationMode.SmoothTransformation, ) image_label.setPixmap(scaled_pixmap) - image_label.setFixedSize(scaled_pixmap.size()) # Set QLabel size to match QPixmap size + image_label.setFixedSize( + scaled_pixmap.size() + ) # Set QLabel size to match QPixmap size border_rgb = Utils.get_rgb(border_color) - image_label.setStyleSheet(f"bpyside6. how do i make this start at the top. top alignedorder: 2px solid {border_rgb};") + image_label.setStyleSheet( + f"bpyside6. how do i make this start at the top. top alignedorder: 2px solid {border_rgb};" + ) return image_label @staticmethod @@ -132,4 +139,4 @@ class Game: interval_ms = Config.loop_delay Game.timer = QTimer() Game.timer.timeout.connect(Game.get_status) - Game.timer.start(interval_ms) \ No newline at end of file + Game.timer.start(interval_ms) diff --git a/cromulant/utils.py b/cromulant/utils.py index 058a426..4b911d1 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -88,4 +88,4 @@ class Utils: @staticmethod def get_rgb(color: tuple[int, int, int]) -> str: - return f"rgb{color}" \ No newline at end of file + return f"rgb{color}" diff --git a/cromulant/window.py b/cromulant/window.py index b4e467f..7d12e92 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -3,13 +3,13 @@ from __future__ import annotations from PySide6.QtWidgets import QApplication # type: ignore from PySide6.QtWidgets import QMainWindow from PySide6.QtWidgets import QWidget -from PySide6.QtWidgets import QGraphicsView from PySide6.QtWidgets import QGraphicsScene from PySide6.QtWidgets import QVBoxLayout from PySide6.QtWidgets import QPushButton from PySide6.QtWidgets import QHBoxLayout from PySide6.QtWidgets import QScrollArea -from PySide6.QtGui import QIcon +from PySide6.QtWidgets import QLayout +from PySide6.QtGui import QIcon # type: ignore from PySide6.QtCore import Qt # type: ignore from .config import Config @@ -18,8 +18,8 @@ from .config import Config class Window: app: QApplication window: QMainWindow - root: QHBoxLayout - view: QGraphicsView + root: QVBoxLayout + view: QVBoxLayout view_scene: QGraphicsScene @staticmethod @@ -34,11 +34,10 @@ class Window: Window.window = QMainWindow() Window.window.setWindowTitle(Config.title) Window.window.resize(Config.width, Config.height) - Window.root = QHBoxLayout() central_widget = QWidget() Window.root = QVBoxLayout() central_widget.setLayout(Window.root) - Window.root.setAlignment(Qt.AlignTop) + Window.root.setAlignment(Qt.AlignmentFlag.AlignTop) Window.window.setCentralWidget(central_widget) Window.window.setWindowIcon(QIcon(str(Config.icon_path))) @@ -74,7 +73,7 @@ class Window: Window.view = QVBoxLayout() parent.addLayout(Window.view) - Window.view.setAlignment(Qt.AlignTop) + Window.view.setAlignment(Qt.AlignmentFlag.AlignTop) scroll_area.setWidget(container) Window.root.addWidget(scroll_area) @@ -100,7 +99,7 @@ class Window: Window.app.quit() @staticmethod - def delete_layout(layout): + def delete_layout(layout: QLayout) -> None: while layout.count(): item = layout.takeAt(0) if item.widget():