29 lines
971 B
Python
29 lines
971 B
Python
from PyQt6 import QtWidgets
|
|
from PyQt6.QtWidgets import QDialog
|
|
|
|
from wargame_campaign.view.ui.ui_main_window import Ui_MainWindow
|
|
from wargame_campaign.view.ui.ui_player_dialog import Ui_playerDialog
|
|
|
|
class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
def __init__(self, parent=None):
|
|
super(View, self).__init__(parent)
|
|
self.setupUi(self)
|
|
|
|
def display_players(self, players: list):
|
|
table = self.playersTable
|
|
table.setRowCount(len(players))
|
|
|
|
for row, player in enumerate(players):
|
|
table.setItem(row, 0, QtWidgets.QTableWidgetItem(player.name))
|
|
table.setItem(row, 1, QtWidgets.QTableWidgetItem(player.id))
|
|
|
|
table.resizeColumnsToContents()
|
|
|
|
class PlayerDialog(QDialog):
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.ui = Ui_playerDialog()
|
|
self.ui.setupUi(self)
|
|
|
|
def get_player_name(self) -> str:
|
|
return self.ui.playerName.text().strip()
|