diff options
author | brenda-br | 2023-02-14 17:17:24 +0530 |
---|---|---|
committer | brenda-br | 2023-02-14 17:17:24 +0530 |
commit | 2a4621e4d7faa62e5df83f9d10feb3a5f72860f9 (patch) | |
tree | 9359d763be0f916d8cfe877af41342ad14499e1f | |
parent | 4c11732b66b321ee645997355a6e15387e441ab9 (diff) | |
download | Chemical-Simulator-GUI-2a4621e4d7faa62e5df83f9d10feb3a5f72860f9.tar.gz Chemical-Simulator-GUI-2a4621e4d7faa62e5df83f9d10feb3a5f72860f9.tar.bz2 Chemical-Simulator-GUI-2a4621e4d7faa62e5df83f9d10feb3a5f72860f9.zip |
Fix #56 Mixer, Distillation Column not added on cancel
-rw-r--r-- | Container.py | 21 | ||||
-rw-r--r-- | Graphics.py | 16 |
2 files changed, 21 insertions, 16 deletions
diff --git a/Container.py b/Container.py index 1471653..8bb1b1d 100644 --- a/Container.py +++ b/Container.py @@ -34,17 +34,18 @@ class Container(): self.obj = obj self.scene = self.graphics.get_scene() box = self.graphics.create_node_item(self.obj, self) - self.scene.addItem(box) - box.setPos(2500-30, 2500-30) + if box is not None: + self.scene.addItem(box) + box.setPos(2500-30, 2500-30) - if(obj in self.unit_operations): - pass - else: - self.unit_operations.append(obj) - data = self.unit_operations[:] - data.append(compound_selected) - push('Undo', data) - self.msg.append("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+obj.name+" </b>is instantiated .""</span>") + if(obj in self.unit_operations): + pass + else: + self.unit_operations.append(obj) + data = self.unit_operations[:] + data.append(compound_selected) + push('Undo', data) + self.msg.append("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+obj.name+" </b>is instantiated .""</span>") ''' Deletes the selected item from the canvas and also the objects created for that type. diff --git a/Graphics.py b/Graphics.py index 4387daa..227ab38 100644 --- a/Graphics.py +++ b/Graphics.py @@ -36,7 +36,11 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): return self.scene def create_node_item(self,unit_operation, container): - return NodeItem(unit_operation, container, self.graphicsView) + tempItem = NodeItem(unit_operation, container, self.graphicsView) + if tempItem.ok: + return tempItem + else: + return None def update_compounds(self): for i in self.graphicsView.items(): @@ -457,7 +461,7 @@ class NodeItem(QtWidgets.QGraphicsItem): self.setAcceptHoverEvents(True) self.name = self.obj.name self.type = self.obj.type - + self.ok = True if (self.obj.modes_list): default_tooltip = f"{self.name}\n\n" default_tooltip_dict = self.obj.param_getter_tooltip(self.obj.mode) @@ -468,9 +472,9 @@ class NodeItem(QtWidgets.QGraphicsItem): if self.obj.type == 'Mixer' and not self.obj.saved: - text, ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input:', + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input:', echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) - if ok and text: + if self.ok and text: self.nin = int(text) self.obj.no_of_inputs = self.nin self.obj.variables['NI']['value'] = self.nin @@ -481,9 +485,9 @@ class NodeItem(QtWidgets.QGraphicsItem): # self.obj.no_of_outputs = self.nop # self.obj.variables['No']['value'] = self.nop elif self.obj.type == 'DistillationColumn'and not self.obj.saved: - text, ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input:', + text, self.ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input:', echo=QLineEdit.Normal, text=str(self.obj.no_of_inputs)) - if ok and text: + if self.ok and text: self.nin = int(text) self.obj.no_of_inputs = self.nin self.obj.variables['Ni']['value'] = self.nin |