-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
51 lines (43 loc) · 1.74 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from PySide6.QtWidgets import QApplication, QMainWindow, QGridLayout, QWidget,\
QPushButton
from PySide6.QtCore import Qt
import sys
from GUI.ArmyClass import Army
from PySide6.QtGui import QFont
import os
import logging
from simulation_thread import simulation_thread
class BattleSim(QMainWindow):
def __init__(self):
try:
QMainWindow.__init__(self)
self.mainWidget=QWidget()
self.font=QFont("Arial",12)
self.sim_thread=simulation_thread()
self.setFont(self.font)
self.setCentralWidget(self.mainWidget)
self.Attacker=Army("Attacking Army")
self.Defender=Army("Defending Army")
self.run_sim_btn=QPushButton("Run Sim")
self.run_sim_btn.clicked.connect(self.run_simulation)
l=QGridLayout()
l.addWidget(self.Attacker,0,0)
l.addWidget(self.Defender,0,1)
self.mainWidget.setLayout(l)
except Exception as e:
exc_type, _, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print('%s:%s in %s at %d'%(exc_type.__name__,str(e), fname, exc_tb.tb_lineno))
logging.error('%s:%s in %s at %d'%(exc_type.__name__,str(e), fname, exc_tb.tb_lineno))
def run_simulation(self):
self.sim_thread.set_armies(self.Attacker,self.Defender)
self.sim_thread.run()
if __name__ == '__main__':
# Handle high resolution displays:
QApplication.setAttribute(Qt.AA_Use96Dpi)
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_Use96Dpi)
# app.setStyle("Fusion")
aw = BattleSim()
aw.show()
app.exec()