dcs-retribution/qt_ui/widgets/QBudgetBox.py
Dan Albert 2a75d14e0e Revert upgrade to pyside6.
This appears to be incompatible with pyinstaller. I get the following
when trying to run the executable generated with pyside6:

```
Traceback (most recent call last):
  File "qt_ui\main.py", line 29, in <module>
  File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "qt_ui\windows\QLiberationWindow.py", line 28, in <module>
  File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "qt_ui\widgets\map\QLiberationMap.py", line 11, in <module>
ImportError: could not import module 'PySide6.QtPrintSupport'
```
2021-11-21 17:39:43 -08:00

50 lines
1.4 KiB
Python

from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QPushButton
import qt_ui.uiconstants as CONST
from game import Game
from game.income import Income
from qt_ui.windows.finances.QFinancesMenu import QFinancesMenu
class QBudgetBox(QGroupBox):
"""
UI Component to display current budget and player's money
"""
def __init__(self, game: Game):
super(QBudgetBox, self).__init__("Budget")
self.game = game
self.finances = QPushButton()
self.finances.setDisabled(True)
self.finances.setProperty("style", "btn-primary")
self.finances.setIcon(CONST.ICONS["Money"])
self.finances.clicked.connect(self.openFinances)
self.layout = QHBoxLayout()
self.layout.addWidget(self.finances)
self.setLayout(self.layout)
def setBudget(self, budget, reward):
"""
Set the money amount to display
:param budget: Current money available
:param reward: Planned reward for next turn
"""
self.finances.setText(
str(round(budget, 2)) + "M (+" + str(round(reward, 2)) + "M)"
)
def setGame(self, game):
if game is None:
return
self.game = game
self.setBudget(self.game.blue.budget, Income(self.game, player=True).total)
self.finances.setEnabled(True)
def openFinances(self):
self.subwindow = QFinancesMenu(self.game)
self.subwindow.show()