From d476d2e053f937c0060f696312f301591e4f43ea Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 23 Feb 2023 22:14:39 +0530 Subject: Restructure Code -1 --- src/main/python/DockWidgets/DockWidget.py | 167 ++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 src/main/python/DockWidgets/DockWidget.py (limited to 'src/main/python/DockWidgets/DockWidget.py') diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py new file mode 100644 index 0000000..a97212a --- /dev/null +++ b/src/main/python/DockWidgets/DockWidget.py @@ -0,0 +1,167 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/DockWidgets/DockWidget.ui') + +class DockWidget(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container, parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = {} + self.modes() + self.comboBox.currentIndexChanged.connect(self.mode_selection) + + print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + + self.dict = {} # a dictionary + self.container = container + + # input data tab + def modes(self): + modes_list = self.obj.modes_list + if(modes_list): + for j in modes_list: + self.comboBox.addItem(str(self.obj.variables[j]['name'])) + self.comboBox.setCurrentText(self.obj.variables[self.obj.mode]['name']) + self.mode_selection() + else: + self.comboBox.setDisabled(True) + self.input_dict= {} + self.input_dict = self.obj.param_getter() + self.input_params_list() + + def mode_selection(self): + self.input_dict= {} + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + print(self.comboBox.currentText()) + for i in self.obj.variables: + if self.obj.variables[i]['name'] == self.comboBox.currentText(): + currentText = i + break + self.input_dict = self.obj.param_getter(currentText) + print('mode selection ', self.input_dict) + self.input_params_list() + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + for c,i in enumerate(self.input_dict): + #print(i) + if i == None: + continue + l = QLineEdit(str(self.obj.variables[i]['value'])) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + self.formLayout.addRow(lay) + self.input_dict[i] = l + except Exception as e: + print(e) + + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict = {} + #print("param.input_dict ", self.input_dict) + for i in self.input_dict: + if (self.input_dict[i] == None): + continue + else: + #print(self.input_dict[i], i, self.obj.type) + if (self.input_dict[i].text()): + self.dict[i] = self.input_dict[i].text() + else: + #print(self.input_dict[i].text()) + self.show_error() + break + + #print("param ", self.dict) + self.obj.param_setter(self.dict) + for i in self.container.graphics.graphicsView.items(): + try: + if(i.name == self.name): + i.update_tooltip() + except: + pass + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + @staticmethod + def show_result(lst): + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + + # result data tab + def results_category(self,name): + flag = True + try: + #print("Under result category name ", name) + result=self.container.result + obj = self.container.fetch_object(name) + self.tableWidget.setRowCount(0) + variKeys = list(obj.variables.keys()) + #print(variKeys) + for i, val in enumerate(variKeys): + propertyname = name + '.' + val + #print(i,val, propertyname) + if propertyname in result[0]: + ind = result[0].index(propertyname) + resultval = str(result[-1][ind]) + #print("######Resultsfetch####",val,resultval) + rowPosition = self.tableWidget.rowCount() + self.tableWidget.insertRow(rowPosition) + self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name'])) + self.tableWidget.setItem(rowPosition , 1, QTableWidgetItem(resultval)) + self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) + self.tableWidget.resizeColumnsToContents() + + # Updating result in class + obj.variables[val]['value'] = resultval + # try: + # if obj.type == "Heater": + # print(obj.variables[val]['name'] + str(obj.variables[val]['value'])) + # except Exception as e: + # print(e) + + + + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) \ No newline at end of file -- cgit From 2b94618c50110c38cd67564a5b58630aeeb2adc5 Mon Sep 17 00:00:00 2001 From: brenda-br Date: Fri, 24 Feb 2023 11:55:27 +0530 Subject: Fix #62 Remove Redundant Lines --- src/main/python/DockWidgets/DockWidget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/python/DockWidgets/DockWidget.py') diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py index a97212a..fcfc172 100644 --- a/src/main/python/DockWidgets/DockWidget.py +++ b/src/main/python/DockWidgets/DockWidget.py @@ -51,13 +51,13 @@ class DockWidget(QDockWidget,ui_dialog): self.input_dict= {} for i in reversed(range(self.formLayout.count())): self.formLayout.removeRow(i) - print(self.comboBox.currentText()) + #print(self.comboBox.currentText()) for i in self.obj.variables: if self.obj.variables[i]['name'] == self.comboBox.currentText(): currentText = i break self.input_dict = self.obj.param_getter(currentText) - print('mode selection ', self.input_dict) + #print('mode selection ', self.input_dict) self.input_params_list() def input_params_list(self): -- cgit From f85ca605c02f70fcd911547323ee1245265b83ab Mon Sep 17 00:00:00 2001 From: brenda-br Date: Wed, 1 Mar 2023 12:49:04 +0530 Subject: DockWidgets Realigning --- src/main/python/DockWidgets/DockWidget.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/python/DockWidgets/DockWidget.py') diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py index fcfc172..764d8fb 100644 --- a/src/main/python/DockWidgets/DockWidget.py +++ b/src/main/python/DockWidgets/DockWidget.py @@ -27,7 +27,7 @@ class DockWidget(QDockWidget,ui_dialog): self.modes() self.comboBox.currentIndexChanged.connect(self.mode_selection) - print("constructor ", self.input_dict) + #print("constructor ", self.input_dict) self.pushButton_2.clicked.connect(self.param) self.dict = {} # a dictionary @@ -62,16 +62,17 @@ class DockWidget(QDockWidget,ui_dialog): def input_params_list(self): try: - print("input_params_list ", self.input_dict) + #print("input_params_list ", self.input_dict) for c,i in enumerate(self.input_dict): #print(i) if i == None: continue l = QLineEdit(str(self.obj.variables[i]['value'])) + l.setFixedWidth(80) lay = QGridLayout() lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) lay.addWidget(l,0,1, alignment=Qt.AlignCenter) - lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignLeft) self.formLayout.addRow(lay) self.input_dict[i] = l except Exception as e: -- cgit From 7af3526e105cc330422f8742ec5edec1c4a0a98f Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 2 Mar 2023 15:49:11 +0530 Subject: Restructuring Finalized for App Bundling --- src/main/python/DockWidgets/DockWidget.py | 168 ------------------------------ 1 file changed, 168 deletions(-) delete mode 100644 src/main/python/DockWidgets/DockWidget.py (limited to 'src/main/python/DockWidgets/DockWidget.py') diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py deleted file mode 100644 index 764d8fb..0000000 --- a/src/main/python/DockWidgets/DockWidget.py +++ /dev/null @@ -1,168 +0,0 @@ -import os, sys - -current = os.path.dirname(os.path.realpath(__file__)) -parent = os.path.dirname(current) -parentPath = os.path.dirname(parent) -sys.path.append(parentPath) - -from PyQt5.QtCore import * -from PyQt5.QtWidgets import * -from PyQt5.QtGui import * -from PyQt5.uic import loadUiType -from python.utils.ComponentSelector import * -from python.utils.Graphics import * - -ui_dialog,_ = loadUiType(parentPath+'/ui/DockWidgets/DockWidget.ui') - -class DockWidget(QDockWidget,ui_dialog): - - def __init__(self,name,comptype,obj,container, parent=None): - QDockWidget.__init__(self,parent) - self.setupUi(self) - self.setWindowTitle(obj.name) - self.name=name - self.obj=obj - self.type = comptype - self.input_dict = {} - self.modes() - self.comboBox.currentIndexChanged.connect(self.mode_selection) - - #print("constructor ", self.input_dict) - self.pushButton_2.clicked.connect(self.param) - - self.dict = {} # a dictionary - self.container = container - - # input data tab - def modes(self): - modes_list = self.obj.modes_list - if(modes_list): - for j in modes_list: - self.comboBox.addItem(str(self.obj.variables[j]['name'])) - self.comboBox.setCurrentText(self.obj.variables[self.obj.mode]['name']) - self.mode_selection() - else: - self.comboBox.setDisabled(True) - self.input_dict= {} - self.input_dict = self.obj.param_getter() - self.input_params_list() - - def mode_selection(self): - self.input_dict= {} - for i in reversed(range(self.formLayout.count())): - self.formLayout.removeRow(i) - #print(self.comboBox.currentText()) - for i in self.obj.variables: - if self.obj.variables[i]['name'] == self.comboBox.currentText(): - currentText = i - break - self.input_dict = self.obj.param_getter(currentText) - #print('mode selection ', self.input_dict) - self.input_params_list() - - def input_params_list(self): - try: - #print("input_params_list ", self.input_dict) - for c,i in enumerate(self.input_dict): - #print(i) - if i == None: - continue - l = QLineEdit(str(self.obj.variables[i]['value'])) - l.setFixedWidth(80) - lay = QGridLayout() - lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) - lay.addWidget(l,0,1, alignment=Qt.AlignCenter) - lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignLeft) - self.formLayout.addRow(lay) - self.input_dict[i] = l - except Exception as e: - print(e) - - - def show_error(self): - QMessageBox.about(self, 'Important', "Please fill all fields with data") - - def param(self): - try: - self.dict = {} - #print("param.input_dict ", self.input_dict) - for i in self.input_dict: - if (self.input_dict[i] == None): - continue - else: - #print(self.input_dict[i], i, self.obj.type) - if (self.input_dict[i].text()): - self.dict[i] = self.input_dict[i].text() - else: - #print(self.input_dict[i].text()) - self.show_error() - break - - #print("param ", self.dict) - self.obj.param_setter(self.dict) - for i in self.container.graphics.graphicsView.items(): - try: - if(i.name == self.name): - i.update_tooltip() - except: - pass - if(self.isVisible()): - currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() - self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) - self.hide() - - except Exception as e: - print(e) - - @staticmethod - def show_result(lst): - for i in lst: - try: - i.results_category(i.name) - except AttributeError: - pass - - def clear_results(self): - self.tableWidget.setRowCount(0) - - # result data tab - def results_category(self,name): - flag = True - try: - #print("Under result category name ", name) - result=self.container.result - obj = self.container.fetch_object(name) - self.tableWidget.setRowCount(0) - variKeys = list(obj.variables.keys()) - #print(variKeys) - for i, val in enumerate(variKeys): - propertyname = name + '.' + val - #print(i,val, propertyname) - if propertyname in result[0]: - ind = result[0].index(propertyname) - resultval = str(result[-1][ind]) - #print("######Resultsfetch####",val,resultval) - rowPosition = self.tableWidget.rowCount() - self.tableWidget.insertRow(rowPosition) - self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name'])) - self.tableWidget.setItem(rowPosition , 1, QTableWidgetItem(resultval)) - self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) - self.tableWidget.resizeColumnsToContents() - - # Updating result in class - obj.variables[val]['value'] = resultval - # try: - # if obj.type == "Heater": - # print(obj.variables[val]['name'] + str(obj.variables[val]['value'])) - # except Exception as e: - # print(e) - - - - except Exception as e: - print(e) - - def closeEvent(self,event): - scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal - currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() - self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) \ No newline at end of file -- cgit From 3cbdd4238867bc860282f7cf702d73b5be6e3f86 Mon Sep 17 00:00:00 2001 From: brenda-br Date: Sat, 4 Mar 2023 11:32:15 +0530 Subject: Revert "Restructuring Finalized for App Bundling" This reverts commit 7af3526e105cc330422f8742ec5edec1c4a0a98f. --- src/main/python/DockWidgets/DockWidget.py | 168 ++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 src/main/python/DockWidgets/DockWidget.py (limited to 'src/main/python/DockWidgets/DockWidget.py') diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py new file mode 100644 index 0000000..764d8fb --- /dev/null +++ b/src/main/python/DockWidgets/DockWidget.py @@ -0,0 +1,168 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/DockWidgets/DockWidget.ui') + +class DockWidget(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container, parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = {} + self.modes() + self.comboBox.currentIndexChanged.connect(self.mode_selection) + + #print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + + self.dict = {} # a dictionary + self.container = container + + # input data tab + def modes(self): + modes_list = self.obj.modes_list + if(modes_list): + for j in modes_list: + self.comboBox.addItem(str(self.obj.variables[j]['name'])) + self.comboBox.setCurrentText(self.obj.variables[self.obj.mode]['name']) + self.mode_selection() + else: + self.comboBox.setDisabled(True) + self.input_dict= {} + self.input_dict = self.obj.param_getter() + self.input_params_list() + + def mode_selection(self): + self.input_dict= {} + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + #print(self.comboBox.currentText()) + for i in self.obj.variables: + if self.obj.variables[i]['name'] == self.comboBox.currentText(): + currentText = i + break + self.input_dict = self.obj.param_getter(currentText) + #print('mode selection ', self.input_dict) + self.input_params_list() + + def input_params_list(self): + try: + #print("input_params_list ", self.input_dict) + for c,i in enumerate(self.input_dict): + #print(i) + if i == None: + continue + l = QLineEdit(str(self.obj.variables[i]['value'])) + l.setFixedWidth(80) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignLeft) + self.formLayout.addRow(lay) + self.input_dict[i] = l + except Exception as e: + print(e) + + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict = {} + #print("param.input_dict ", self.input_dict) + for i in self.input_dict: + if (self.input_dict[i] == None): + continue + else: + #print(self.input_dict[i], i, self.obj.type) + if (self.input_dict[i].text()): + self.dict[i] = self.input_dict[i].text() + else: + #print(self.input_dict[i].text()) + self.show_error() + break + + #print("param ", self.dict) + self.obj.param_setter(self.dict) + for i in self.container.graphics.graphicsView.items(): + try: + if(i.name == self.name): + i.update_tooltip() + except: + pass + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + @staticmethod + def show_result(lst): + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + + # result data tab + def results_category(self,name): + flag = True + try: + #print("Under result category name ", name) + result=self.container.result + obj = self.container.fetch_object(name) + self.tableWidget.setRowCount(0) + variKeys = list(obj.variables.keys()) + #print(variKeys) + for i, val in enumerate(variKeys): + propertyname = name + '.' + val + #print(i,val, propertyname) + if propertyname in result[0]: + ind = result[0].index(propertyname) + resultval = str(result[-1][ind]) + #print("######Resultsfetch####",val,resultval) + rowPosition = self.tableWidget.rowCount() + self.tableWidget.insertRow(rowPosition) + self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name'])) + self.tableWidget.setItem(rowPosition , 1, QTableWidgetItem(resultval)) + self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) + self.tableWidget.resizeColumnsToContents() + + # Updating result in class + obj.variables[val]['value'] = resultval + # try: + # if obj.type == "Heater": + # print(obj.variables[val]['name'] + str(obj.variables[val]['value'])) + # except Exception as e: + # print(e) + + + + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) \ No newline at end of file -- cgit