warchron_app/src/warchron/view/war_dialog.py

24 lines
711 B
Python

from PyQt6.QtWidgets import QWidget, QDialog
from warchron.view.ui.ui_war_dialog import Ui_warDialog
class WarDialog(QDialog):
def __init__(
self,
parent: QWidget | None = None,
default_name: str = "",
default_year: int | None = None,
) -> None:
super().__init__(parent)
self.ui: Ui_warDialog = Ui_warDialog()
self.ui.setupUi(self) # type: ignore
self.ui.warName.setText(default_name)
if default_year is not None:
self.ui.warYear.setValue(default_year)
def get_war_name(self) -> str:
return self.ui.warName.text().strip()
def get_war_year(self) -> int:
return int(self.ui.warYear.value())