Mods
This commit is contained in:
		@@ -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)
 | 
			
		||||
            Ants.ants.append(ant)
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
        Game.timer.start(interval_ms)
 | 
			
		||||
 
 | 
			
		||||
@@ -88,4 +88,4 @@ class Utils:
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def get_rgb(color: tuple[int, int, int]) -> str:
 | 
			
		||||
        return f"rgb{color}"
 | 
			
		||||
        return f"rgb{color}"
 | 
			
		||||
 
 | 
			
		||||
@@ -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():
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user