Mods
This commit is contained in:
parent
d989ac45a8
commit
0579aa140d
|
@ -37,7 +37,9 @@ class Ant:
|
||||||
self.status = data["status"]
|
self.status = data["status"]
|
||||||
self.hits = data["hits"]
|
self.hits = data["hits"]
|
||||||
self.triumph = data["triumph"]
|
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:
|
def get_name(self) -> str:
|
||||||
return self.name or "Nameless"
|
return self.name or "Nameless"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import random
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from PySide6.QtCore import Qt # type: ignore
|
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 QVBoxLayout
|
||||||
from PySide6.QtWidgets import QLabel
|
from PySide6.QtWidgets import QLabel
|
||||||
from PySide6.QtGui import QPixmap # type: ignore
|
from PySide6.QtGui import QPixmap # type: ignore
|
||||||
|
@ -62,7 +62,7 @@ class Game:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def make_right_container(title: str, message: str) -> QVBoxLayout:
|
def make_right_container(title: str, message: str) -> QVBoxLayout:
|
||||||
container = QVBoxLayout()
|
container = QVBoxLayout()
|
||||||
container.setAlignment(Qt.AlignTop)
|
container.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||||
title_label = QLabel(title)
|
title_label = QLabel(title)
|
||||||
title_label.setStyleSheet("font-weight: bold;")
|
title_label.setStyleSheet("font-weight: bold;")
|
||||||
message_label = QLabel(message)
|
message_label = QLabel(message)
|
||||||
|
@ -76,13 +76,20 @@ class Game:
|
||||||
pixmap = QPixmap(str(image_path))
|
pixmap = QPixmap(str(image_path))
|
||||||
|
|
||||||
scaled_pixmap = pixmap.scaled(
|
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.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)
|
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
|
return image_label
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -3,13 +3,13 @@ from __future__ import annotations
|
||||||
from PySide6.QtWidgets import QApplication # type: ignore
|
from PySide6.QtWidgets import QApplication # type: ignore
|
||||||
from PySide6.QtWidgets import QMainWindow
|
from PySide6.QtWidgets import QMainWindow
|
||||||
from PySide6.QtWidgets import QWidget
|
from PySide6.QtWidgets import QWidget
|
||||||
from PySide6.QtWidgets import QGraphicsView
|
|
||||||
from PySide6.QtWidgets import QGraphicsScene
|
from PySide6.QtWidgets import QGraphicsScene
|
||||||
from PySide6.QtWidgets import QVBoxLayout
|
from PySide6.QtWidgets import QVBoxLayout
|
||||||
from PySide6.QtWidgets import QPushButton
|
from PySide6.QtWidgets import QPushButton
|
||||||
from PySide6.QtWidgets import QHBoxLayout
|
from PySide6.QtWidgets import QHBoxLayout
|
||||||
from PySide6.QtWidgets import QScrollArea
|
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 PySide6.QtCore import Qt # type: ignore
|
||||||
|
|
||||||
from .config import Config
|
from .config import Config
|
||||||
|
@ -18,8 +18,8 @@ from .config import Config
|
||||||
class Window:
|
class Window:
|
||||||
app: QApplication
|
app: QApplication
|
||||||
window: QMainWindow
|
window: QMainWindow
|
||||||
root: QHBoxLayout
|
root: QVBoxLayout
|
||||||
view: QGraphicsView
|
view: QVBoxLayout
|
||||||
view_scene: QGraphicsScene
|
view_scene: QGraphicsScene
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -34,11 +34,10 @@ class Window:
|
||||||
Window.window = QMainWindow()
|
Window.window = QMainWindow()
|
||||||
Window.window.setWindowTitle(Config.title)
|
Window.window.setWindowTitle(Config.title)
|
||||||
Window.window.resize(Config.width, Config.height)
|
Window.window.resize(Config.width, Config.height)
|
||||||
Window.root = QHBoxLayout()
|
|
||||||
central_widget = QWidget()
|
central_widget = QWidget()
|
||||||
Window.root = QVBoxLayout()
|
Window.root = QVBoxLayout()
|
||||||
central_widget.setLayout(Window.root)
|
central_widget.setLayout(Window.root)
|
||||||
Window.root.setAlignment(Qt.AlignTop)
|
Window.root.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||||
Window.window.setCentralWidget(central_widget)
|
Window.window.setCentralWidget(central_widget)
|
||||||
Window.window.setWindowIcon(QIcon(str(Config.icon_path)))
|
Window.window.setWindowIcon(QIcon(str(Config.icon_path)))
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ class Window:
|
||||||
Window.view = QVBoxLayout()
|
Window.view = QVBoxLayout()
|
||||||
parent.addLayout(Window.view)
|
parent.addLayout(Window.view)
|
||||||
|
|
||||||
Window.view.setAlignment(Qt.AlignTop)
|
Window.view.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||||
scroll_area.setWidget(container)
|
scroll_area.setWidget(container)
|
||||||
Window.root.addWidget(scroll_area)
|
Window.root.addWidget(scroll_area)
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ class Window:
|
||||||
Window.app.quit()
|
Window.app.quit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_layout(layout):
|
def delete_layout(layout: QLayout) -> None:
|
||||||
while layout.count():
|
while layout.count():
|
||||||
item = layout.takeAt(0)
|
item = layout.takeAt(0)
|
||||||
if item.widget():
|
if item.widget():
|
||||||
|
|
Loading…
Reference in New Issue