mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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' ```
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from PySide2.QtWidgets import QButtonGroup, QHBoxLayout, QPushButton, QWidget
|
|
|
|
from game.sim.simspeedsetting import SimSpeedSetting
|
|
from qt_ui.simcontroller import SimController
|
|
|
|
|
|
class SimSpeedControls(QHBoxLayout):
|
|
def __init__(
|
|
self, sim_controller: SimController, parent: Optional[QWidget] = None
|
|
) -> None:
|
|
super().__init__(parent)
|
|
self.sim_controller = sim_controller
|
|
self.button_group = QButtonGroup(self)
|
|
self.buttons: dict[SimSpeedSetting, QPushButton] = {}
|
|
|
|
for speed_setting in SimSpeedSetting:
|
|
button = QPushButton(speed_setting.text)
|
|
button.setCheckable(True) # TODO: CSS
|
|
self.button_group.addButton(button, id=speed_setting.speed_factor)
|
|
self.addWidget(button)
|
|
self.buttons[speed_setting] = button
|
|
|
|
self.button_group.idPressed.connect(self.speed_changed)
|
|
self.sim_controller.sim_speed_reset.connect(self.on_sim_speed_reset)
|
|
|
|
def speed_changed(self, speed_factor: int) -> None:
|
|
setting = SimSpeedSetting.from_factor(speed_factor)
|
|
self.sim_controller.set_simulation_speed(setting)
|
|
|
|
def on_sim_speed_reset(self, speed_setting: SimSpeedSetting) -> None:
|
|
self.buttons[speed_setting].setChecked(True)
|