Index: config.json =================================================================== diff -u --- config.json (revision 0) +++ config.json (revision 552cde1b884edc9f5fc7c1930b7cc39e3fd4bbe9) @@ -0,0 +1,3 @@ +{ + "SW":true +} Index: engine/dynamicloader.py =================================================================== diff -u -rd711fdaf5fdcd83ec84ec7a05965768429483c29 -r552cde1b884edc9f5fc7c1930b7cc39e3fd4bbe9 --- engine/dynamicloader.py (.../dynamicloader.py) (revision d711fdaf5fdcd83ec84ec7a05965768429483c29) +++ engine/dynamicloader.py (.../dynamicloader.py) (revision 552cde1b884edc9f5fc7c1930b7cc39e3fd4bbe9) @@ -2,10 +2,11 @@ find and loads the ui objects """ import os -from PySide2.QtUiTools import QUiLoader -from PySide2.QtCore import QFile, QObject -from PySide2 import QtWidgets +from PySide2.QtUiTools import QUiLoader +from PySide2.QtCore import QFile, QObject +from PySide2 import QtWidgets +from typing import Any class DynamicLoader(QObject): """ @@ -72,132 +73,14 @@ """ self.window.show() - def find_widget(self, child_type, child_name: str) -> QtWidgets.QWidget: - """ - finds a child in the loaded ui and returns the reference to it if found - otherwise quits the application - :param child_type: (var) type of the child - :param child_name: (str) name of the child - :return: (QtWidgets.QWidget) reference to the child - """ - child: QtWidgets.QWidget = self.window.findChild(child_type, child_name) - assert child is not None, "child name '{}' with type '{}' can't be found.".format(child_name, child_type) - return child - - def find_action(self, name: str) -> QtWidgets.QAction: - """ - convenient method of find_widget for QAction - :param name: (str) name of the QLabel Object - :return: (QAction) reference to the QAction - """ - child = self.find_widget(QtWidgets.QAction, name) - return child - - def find_label(self, name: str) -> QtWidgets.QLabel: - """ - convenient method of find_widget for QLabel - :param name: (str) name of the QLabel Object - :return: (QLabel) reference to the QLabel - """ - child = self.find_widget(QtWidgets.QLabel, name) - return child - - def find_line_edit(self, name: str) -> QtWidgets.QLineEdit: - """ - convenient method of find_widget for QLineEdit - :param name: (str) name of the QLabel Object - :return: (QLabel) reference to the QLineEdit - """ - child = self.find_widget(QtWidgets.QLineEdit, name) - return child - - def find_button(self, name: str) -> QtWidgets.QPushButton: - """ - convenient method of find_widget for QPushButton - :param name: (str) name of the QPushButton Object - :return: (QPushButton) reference to the QPushButton - """ - child = self.find_widget(QtWidgets.QPushButton, name) - return child - - def find_combobox(self, name: str) -> QtWidgets.QComboBox: - """ - convenient method of find_widget for QComboBox - :param name: (str) name of the QComboBox Object - :return: (QComboBox) reference to the QComboBox - """ - child = self.find_widget(QtWidgets.QComboBox, name) - return child - - def find_checkbox(self, name: str) -> QtWidgets.QCheckBox: - """ - convenient method of find_widget for QCheckBox - :param name: (str) name of the QCheckBox Object - :return: (QCheckBox) reference to the QComboBox - """ - child = self.find_widget(QtWidgets.QCheckBox, name) - return child - - def find_spinbox(self, name: str) -> QtWidgets.QSpinBox: - """ - convenient method of find_widget for QSpinBox - :param name: (str) name of the QSpinBox Object - :return: (QSpinBox) reference to the QSpinBox - """ - child = self.find_widget(QtWidgets.QSpinBox, name) - return child - - def find_double_spinbox(self, name: str) -> QtWidgets.QDoubleSpinBox: - """ - convenient method of find_widget for QDoubleSpinBox - :param name: (str) name of the QDoubleSpinBox Object - :return: (QDoubleSpinBox) reference to the QDoubleSpinBox - """ - child = self.find_widget(QtWidgets.QDoubleSpinBox, name) - return child - - def find_radio_button(self, name: str) -> QtWidgets.QRadioButton: - """ - convenient method of find_widget for QRadioButton - :param name: (str) name of the QRadioButton Object - :return: (QRadioButton) reference to the QSpinBox - """ - child = self.find_widget(QtWidgets.QRadioButton, name) - return child - - def find_slider(self, name: str) -> QtWidgets.QSlider: - """ - convenient method of find_widget for QSlider - :param name: (str) name of the QSlider Object - :return: (QSlider) reference to the QSlider - """ - child = self.find_widget(QtWidgets.QSlider, name) - return child - - def find_table_widget(self, name: str) -> QtWidgets.QTableWidget: - """ - convenient method of find_widget for QTableWidget - :param name: (str) name of the QTableWidget Object - :return: (QTableWidget) reference to the QTableWidget - """ - child: QtWidgets.QTableWidget = self.find_widget(QtWidgets.QTableWidget, name) - return child - - def find_list_widget(self, name: str) -> QtWidgets.QListWidget: - """ - convenient method of find_widget for QListWidget - :param name: (str) name of the QListWidget Object - :return: (QListWidget) reference to the QListWidget - """ - child: QtWidgets.QListWidget = self.find_widget(QtWidgets.QListWidget, name) - return child - - def find_tool_button(self, name: str) -> QtWidgets.QToolButton: - """ - convenient method of find_widget for QToolButton - :param name: (str) name of the QToolButton Object - :return: (QToolButton) reference to the QToolButton - """ - child: QtWidgets.QToolButton = self.find_widget(QtWidgets.QToolButton, name) - return child - + def find_widget(self, child_type, child_name: str): + """ + finds a child in the loaded ui and returns the reference to it if found + otherwise quits the application + :param child_type: (var) type of the child + :param child_name: (str) name of the child + :return: (QtWidgets.QWidget) reference to the child + """ + child = self.window.findChild(child_type, child_name) + assert child is not None, "child name '{}' with type '{}' can't be found.".format(child_name, child_type) + return child Index: engine/engine.py =================================================================== diff -u -rd711fdaf5fdcd83ec84ec7a05965768429483c29 -r552cde1b884edc9f5fc7c1930b7cc39e3fd4bbe9 --- engine/engine.py (.../engine.py) (revision d711fdaf5fdcd83ec84ec7a05965768429483c29) +++ engine/engine.py (.../engine.py) (revision 552cde1b884edc9f5fc7c1930b7cc39e3fd4bbe9) @@ -19,11 +19,6 @@ and can be eventually shown. Note: this class is growing fast and seems like needs to be multiple classes """ - mdiArea: QtWidgets.QMdiArea - menuBar: QtWidgets.QMenuBar - menuWindows: QtWidgets.QMenu - lblStatusCANBus: QtWidgets.QLabel - lblStatusMessages: QtWidgets.QLabel plugins = [] @@ -38,12 +33,12 @@ initializes the class by calling it's initializer methods to make objects ready :return: none """ - self.lblStatusCANBus = self.find_label('lblStatusCANBus') - self.lblStatusMessages = self.find_label('lblStatusMessages') - self.mdiArea = self.find_widget(QtWidgets.QMdiArea, 'mdiArea') - self.menuBar = self.find_widget(QtWidgets.QMenuBar, 'menuBar') - self.menuWindows = self.find_widget(QtWidgets.QMenu, 'menuWindows') - self.action_show_all = self.find_action('actionShowAll') + self.lblStatusCANBus = self.find_widget(QtWidgets.QLabel , 'lblStatusCANBus') + self.lblStatusMessages = self.find_widget(QtWidgets.QLabel , 'lblStatusMessages') + self.mdiArea = self.find_widget(QtWidgets.QMdiArea , 'mdiArea') + self.menuBar = self.find_widget(QtWidgets.QMenuBar , 'menuBar') + self.menuWindows = self.find_widget(QtWidgets.QMenu , 'menuWindows') + self.action_show_all = self.find_widget(QtWidgets.QAction , 'actionShowAll') def _init_widgets(self): pass