mirror of
https://github.com/naruxde/revpicommander.git
synced 2025-11-08 16:43:53 +01:00
Replace widget search to widget dict (performance)
This commit is contained in:
@@ -15,7 +15,7 @@ from ui.aclmanager_ui import Ui_diag_aclmanager
|
||||
class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
||||
"""ACL manager."""
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent=None):
|
||||
super(AclManager, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setFixedSize(self.size())
|
||||
|
||||
@@ -29,6 +29,9 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
self.setWindowTitle("{0} - {1}".format(position, name))
|
||||
self.gb_io.setTitle(self.gb_io.title().format(name))
|
||||
|
||||
self.__qwa = {}
|
||||
"""Quick widget access."""
|
||||
|
||||
self.position = position
|
||||
self.name = name
|
||||
self.inputs = inputs.copy()
|
||||
@@ -72,6 +75,7 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
name = val.objectName()
|
||||
if name not in lst_names:
|
||||
# Remove old io from layout
|
||||
del self.__qwa[name]
|
||||
layout.removeRow(layout.getWidgetPosition(val)[0])
|
||||
|
||||
counter = -1
|
||||
@@ -147,6 +151,7 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
val.valueChanged.connect(self._change_sbx_dvalue)
|
||||
|
||||
val.setObjectName(name)
|
||||
self.__qwa[name] = val
|
||||
return val
|
||||
|
||||
@QtCore.pyqtSlot(int)
|
||||
@@ -267,7 +272,8 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
:param io_name: Name of IO
|
||||
:return: (actual value, last value) <class 'tuple'>
|
||||
"""
|
||||
child = self.findChild(self.search_class, io_name)
|
||||
# child = self.findChild(self.search_class, io_name)
|
||||
child = self.__qwa[io_name]
|
||||
actual_value = child.value()
|
||||
last_value = child.value() if child.property("last_value") is None else child.property("last_value")
|
||||
if child.property("frm"):
|
||||
@@ -285,7 +291,8 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
:param io_name: Name of IO
|
||||
:param value: Process value as <class 'bool'> or <class 'bytes'>
|
||||
"""
|
||||
child = self.findChild(self.search_class, io_name)
|
||||
# child = self.findChild(self.search_class, io_name)
|
||||
child = self.__qwa[io_name]
|
||||
if child.property("frm"):
|
||||
value = struct.unpack(child.property("frm"), value)[0]
|
||||
elif type(value) == bytearray:
|
||||
@@ -300,7 +307,8 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
:param io_name: Name of IO
|
||||
:param value: New value as bytes or bool for widget
|
||||
"""
|
||||
child = self.findChild(self.search_class, io_name)
|
||||
# child = self.findChild(self.search_class, io_name)
|
||||
child = self.__qwa[io_name]
|
||||
if child.property("frm"):
|
||||
value = struct.unpack(child.property("frm"), value)[0]
|
||||
elif type(value) == bytearray:
|
||||
|
||||
@@ -14,7 +14,7 @@ from ui.mqttmanager_ui import Ui_diag_mqtt
|
||||
class MqttManager(QtWidgets.QDialog, Ui_diag_mqtt):
|
||||
"""MQTT settings for option window."""
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent=None):
|
||||
super(MqttManager, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setFixedSize(self.size())
|
||||
|
||||
@@ -52,7 +52,7 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
||||
# Load sub windows
|
||||
self.diag_connections = RevPiPlcList(self)
|
||||
self.diag_search = AvahiSearch(self)
|
||||
self.diag_info = RevPiInfo(self, __version__)
|
||||
self.diag_info = RevPiInfo(__version__, self)
|
||||
self.diag_options = RevPiOption(self)
|
||||
self.diag_program = RevPiProgram(self)
|
||||
self.win_log = revpilogfile.RevPiLogfile(self)
|
||||
|
||||
@@ -13,7 +13,7 @@ from ui.revpiinfo_ui import Ui_diag_revpiinfo
|
||||
class RevPiInfo(QtWidgets.QDialog, Ui_diag_revpiinfo):
|
||||
"""Version information window."""
|
||||
|
||||
def __init__(self, parent, version: str):
|
||||
def __init__(self, version: str, parent=None):
|
||||
super(RevPiInfo, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class DataThread(QtCore.QThread):
|
||||
class RevPiLogfile(QtWidgets.QMainWindow, Ui_win_revpilogfile):
|
||||
"""Log file viewer for daemon and plc program log."""
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent=None):
|
||||
u"""Init RevPiLogfile-Class."""
|
||||
super(RevPiLogfile, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
@@ -16,7 +16,7 @@ from ui.revpioption_ui import Ui_diag_options
|
||||
class RevPiOption(QtWidgets.QDialog, Ui_diag_options):
|
||||
"""Set options of RevPiPyLoad."""
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent=None):
|
||||
super(RevPiOption, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setFixedSize(self.size())
|
||||
|
||||
Reference in New Issue
Block a user