diff options
-rw-r--r-- | Graphics.py | 169 | ||||
-rw-r--r-- | Streams.py | 3 | ||||
-rw-r--r-- | UnitOperations.py | 27 | ||||
-rw-r--r-- | container.py | 27 | ||||
-rw-r--r-- | mainApp.py | 56 | ||||
-rw-r--r-- | resDockWidget.py | 2 |
6 files changed, 124 insertions, 160 deletions
diff --git a/Graphics.py b/Graphics.py index 80d28ca..d2a56d2 100644 --- a/Graphics.py +++ b/Graphics.py @@ -14,24 +14,22 @@ from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent import PyQt5.QtGui as QtGui import PyQt5.QtCore as QtCore import PyQt5.QtWidgets as QtWidgets -from component_selector import componentSelector from component_selector import * from dockWidget import dockWidget -from resDockWidget import resdockWidget import datetime from container import * from Streams import * from UnitOperations import * - class Graphics(QDialog, QtWidgets.QGraphicsItem): - def __init__(self): + def __init__(self, unitOp): QDialog.__init__(self) QtWidgets.QGraphicsItem.__init__(self) self.scene = QGraphicsScene() self.scene.setItemIndexMethod(QGraphicsScene.BspTreeIndex) self.pos = None + self.unitOp = unitOp def getScene(self): return self.scene @@ -44,36 +42,28 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): def boundingRect(self): return QtCore.QRectF(self.rect) - - def mouseDoubleClickEvent(self, event): - print("Hello") - self.pos = event.scenePos() - print(self.pos) - return super().mouseDoubleClickEvent() def loadCanvas(self, obj): stm = ['MaterialStream','EngStm'] compounds = obj[-1] obj.pop() - componentSelector.setCompounds(compounds) - + for i in obj: - if(i in unitOp): - pass + if(i in self.unitOp): + pass else: - unitOp.append(i) + self.unitOp.append(i) new_box = self.createNodeItem(i) - self.scene.addItem(new_box) new_box.setPos(i.pos.toPoint().x(), i.pos.toPoint().y()) - + self.scene.addItem(new_box) + for i in obj: if i.type == "MaterialStream": eval(i.type).counter += 1 elif i.type not in stm: - #eval(i.type+"Class").counter += 1 - #print(eval(i.type+"Class")) + eval(i.type).counter += 1 ip = i.InputStms op = i.OutputStms for j in ip: @@ -86,14 +76,14 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): pointBB = QtCore.QPointF(rectB.x() + rectB.width()/2, rectB.y() + rectB.height()/2) pointBB = pointB.Input[0].mapToScene(pointBB) self.new_line = NodeLine(pointAA, pointBB, 'in') - #self.new_line = NodeLine(pointA.Output[0].scenePos(), pointB.Input[0].scenePos(), 'in') self.new_line.source = pointA.Output[0] self.new_line.target = pointB.Input[0] pointA.Output[0].outLines.append(self.new_line) pointB.Input[0].inLines.append(self.new_line) + pointA.Output[0].otherLine = self.new_line + pointB.Input[0].otherLine = self.new_line self.scene.addItem(self.new_line) - self.new_line.draw() - #print(pointA.Output[0].outLines[0].source, pointB.Input[0].inLines) + self.new_line.updatePath() for k in op: pointA = NodeItem.getInstances(i.name) pointB = NodeItem.getInstances(k.name) @@ -108,14 +98,12 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): self.new_line.target = pointB.Input[0] pointA.Output[0].outLines.append(self.new_line) pointB.Input[0].inLines.append(self.new_line) + pointA.Output[0].otherLine = self.new_line + pointB.Input[0].otherLine = self.new_line self.scene.addItem(self.new_line) - self.new_line.draw() - #print(pointA.Output[0].outLines, pointB.Input[0].inLines) + self.new_line.updatePath() - - - - + class NodeLine(QtWidgets.QGraphicsPathItem): def __init__(self, pointA, pointB , socket): super(NodeLine, self).__init__() @@ -144,33 +132,61 @@ class NodeLine(QtWidgets.QGraphicsPathItem): path.moveTo(pt1) path.cubicTo(ctrl1_1, ctrl2_1, pt1) - ctrl1_2 = QtCore.QPointF(midptx, self.pointB.y()) - ctrl2_2 = QtCore.QPointF(midptx, self.pointB.y()) - pt2 = QtCore.QPointF(midptx , max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - path.cubicTo(ctrl1_2, ctrl2_2, pt2) - path.moveTo(pt2) - - ctrl1_3 = QtCore.QPointF(midptx, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - ctrl2_3 = QtCore.QPointF(midptx, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - pt3 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - path.cubicTo(ctrl1_3, ctrl2_3, pt3) - path.moveTo(pt3) - - ctrl1_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - ctrl2_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) - pt4 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) - path.cubicTo(ctrl1_4, ctrl2_4, pt4) - path.moveTo(pt4) - - ctrl1_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) - ctrl2_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) - pt5 = QtCore.QPointF(self.pointB.x(), self.pointB.y()) - path.cubicTo(ctrl1_5, ctrl2_5, pt5) - path.moveTo(pt5) - - self.setPath(path) - return - + if abs(self.pointB.x()-midptx) > 150: + ctrl1_2 = QtCore.QPointF(midptx, self.pointB.y()) + ctrl2_2 = QtCore.QPointF(midptx, self.pointB.y()) + pt2 = QtCore.QPointF(midptx , self.pointA.y()+100) + path.cubicTo(ctrl1_2, ctrl2_2, pt2) + path.moveTo(pt2) + + ctrl1_3 = QtCore.QPointF(midptx, self.pointA.y()+100) + ctrl2_3 = QtCore.QPointF(midptx, self.pointA.y()+100) + pt3 = QtCore.QPointF(self.pointB.x()-13, self.pointA.y()+100) + path.cubicTo(ctrl1_3, ctrl2_3, pt3) + path.moveTo(pt3) + + ctrl1_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + ctrl2_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + pt4 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + path.cubicTo(ctrl1_4, ctrl2_4, pt4) + path.moveTo(pt4) + + ctrl1_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + ctrl2_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + pt5 = QtCore.QPointF(self.pointB.x(), self.pointB.y()) + path.cubicTo(ctrl1_5, ctrl2_5, pt5) + path.moveTo(pt5) + + self.setPath(path) + return + else: + ctrl1_2 = QtCore.QPointF(midptx, self.pointB.y()) + ctrl2_2 = QtCore.QPointF(midptx, self.pointB.y()) + pt2 = QtCore.QPointF(midptx , max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + path.cubicTo(ctrl1_2, ctrl2_2, pt2) + path.moveTo(pt2) + + ctrl1_3 = QtCore.QPointF(midptx, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + ctrl2_3 = QtCore.QPointF(midptx, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + pt3 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + path.cubicTo(ctrl1_3, ctrl2_3, pt3) + path.moveTo(pt3) + + ctrl1_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + ctrl2_4 = QtCore.QPointF(self.pointB.x()-13, max(self.pointB.y(), self.pointA.y())-(abs(self.pointA.y()-self.pointB.y())/2)) + pt4 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + path.cubicTo(ctrl1_4, ctrl2_4, pt4) + path.moveTo(pt4) + + ctrl1_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + ctrl2_5 = QtCore.QPointF(self.pointB.x()-13, self.pointB.y()) + pt5 = QtCore.QPointF(self.pointB.x(), self.pointB.y()) + path.cubicTo(ctrl1_5, ctrl2_5, pt5) + path.moveTo(pt5) + + self.setPath(path) + return + path = QtGui.QPainterPath() path.moveTo(self.pointA) midptx = 0.5*(self.pointA.x() + self.pointB.x()) @@ -179,27 +195,23 @@ class NodeLine(QtWidgets.QGraphicsPathItem): ctrl2_1 = QtCore.QPointF(self.pointA.x(), self.pointA.y()) pt1 = QtCore.QPointF(midptx , self.pointA.y()) path.cubicTo(ctrl1_1, ctrl2_1, pt1) - #path.moveTo(pt1) + path.moveTo(pt1) ctrl1_2 = QtCore.QPointF(midptx, self.pointB.y()) ctrl2_2 = QtCore.QPointF(midptx, self.pointB.y()) pt2 = QtCore.QPointF(midptx , self.pointB.y()) path.cubicTo(ctrl1_2, ctrl2_2, pt2) - #path.moveTo(pt2) + path.moveTo(pt2) ctrl1_3 = QtCore.QPointF(midptx, self.pointB.y()) ctrl2_3 = QtCore.QPointF(midptx, self.pointB.y()) path.cubicTo(ctrl1_3, ctrl2_3, self.pointB) - #path.cubicTo(ctrl1_3, ctrl2_3, self.pointB) - #path.moveTo(self.pointB) + path.moveTo(self.pointB) self.setPath(path) def paint(self, painter, option, widget): painter.setPen(self.pen) painter.drawPath(self.path()) - - def draw(self): - self.updatePath() @property def pointA(self): @@ -241,8 +253,6 @@ class NodeLine(QtWidgets.QGraphicsPathItem): del self._pointA del self._pointB -# this is used to store the position of node socket when it is double clicked -lstt = [] class NodeSocket(QtWidgets.QGraphicsItem): def __init__(self, rect, parent, socketType): super(NodeSocket, self).__init__(parent) @@ -266,16 +276,6 @@ class NodeSocket(QtWidgets.QGraphicsItem): self.outLines = [] self.inLines = [] - def drawLoop(self, pointA, pointB): - line1 = QLineF(pointA.x(), pointA.y(), pointA.x(), pointA.y()+200) - line2 = QLineF(pointB.x(), pointB.y(), pointB.x(), min(pointA.y(),pointB.y()) +200) - line3 = QLineF(pointB.x(), min(pointA.y(),pointB.y()) +200, pointA.x(), pointA.y()+200) - self.scene().addLine(line1, self.pen) - self.scene().addLine(line2, self.pen) - self.scene().addLine(line3, self.pen) - - - def shape(self): path = QtGui.QPainterPath() path.addEllipse(self.boundingRect()) @@ -353,30 +353,15 @@ class NodeSocket(QtWidgets.QGraphicsItem): self.outLines.remove(self.newLine) del self.newLine super(NodeSocket, self).mouseReleaseEvent(event) - - - - def mouseDoubleClickEvent(self, event): - if (len(lstt)== 0): - lstt.append(self.mapToScene(event.pos())) - print(lstt) - else: - print("clicked") - print("before fun") - self.drawLoop(self.mapToScene(event.pos()), lstt[-1]) - lstt.clear() - - super(NodeSocket, self).mouseDoubleClickEvent(event) def getCenter(self): rect = self.boundingRect() center = QtCore.QPointF(rect.x() + rect.width()/2, rect.y() + rect.height()/2) center = self.mapToScene(center) return center - # all created node items will be put inside this list -# it is used for returning the node item object based on unit operation object's name +# it is used for recreating the node lines by returning the node item object based on unit operation object's name lst = [] class NodeItem(QtWidgets.QGraphicsItem): @@ -489,17 +474,15 @@ class NodeItem(QtWidgets.QGraphicsItem): for line in output.outLines: line.pointA = line.source.getCenter() line.pointB = line.target.getCenter() - #print(line.source) for input in self.Input: for line in input.inLines: line.pointA = line.source.getCenter() line.pointB = line.target.getCenter() - #print(line.source) self.pos = event.scenePos() self.obj.setPos(self.pos) def mouseDoubleClickEvent(self, event): - #self.setPos(event.scenePos().x()-250,event.scenePos().y()) + self.setPos(event.scenePos().x()-250,event.scenePos().y()) self.dockWidget.show() def findMainWindow(self): @@ -1,4 +1,5 @@ from OMPython import OMCSession +from PyQt5.QtCore import * import json import sys from collections import defaultdict @@ -31,7 +32,7 @@ class MaterialStream(): self.no_of_outputs = 1 self.x = 2500-30 self.y = 2500-30 - self.pos = None + self.pos = QPointF(self.x, self.y) MaterialStream.counter+=1 self.startDict = {} self.eqnDict = {} diff --git a/UnitOperations.py b/UnitOperations.py index 979f080..b3b9a95 100644 --- a/UnitOperations.py +++ b/UnitOperations.py @@ -1,5 +1,4 @@ from OMChem.Flowsheet import Flowsheet -from Graphics import Graphics from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtGui import QTextDocument ,QTextCursor ,QTextCharFormat ,QFont ,QPixmap @@ -30,11 +29,10 @@ class UnitOperation(): self.Prop = {} self.x = 2500-30 self.y = 2500-30 - self.pos = None + self.pos = QPointF(self.x, self.y) self.Prop = {} self.modeslist = [] self.parameters = {} - # self.input_parameters = {} self.extra = [] self.ForNaming = [] self.multidict = [] @@ -85,8 +83,6 @@ class UnitOperation(): latest += self.extra[i][j] self.ForNaming[i] = latest - - if(self.ThermoPackReq): if len(self.extra)==1: for i in self.extra: @@ -96,7 +92,6 @@ class UnitOperation(): self.OM_data_init += ('end '+i+str(self.counter)+';\n') self.OM_data_init += i+str(self.counter) + ' ' + self.name + '(Nc = ' + str(len(self.compounds)) - else: for i in range(len(self.extra)): if i!=(len(self.extra)-1): @@ -116,9 +111,7 @@ class UnitOperation(): C = str(self.compounds).strip('[').strip(']') C = C.replace("'", "") - self.OM_data_init += ',C = {' + C + '}' - - + self.OM_data_init += ',C = {' + C + '}' for k,v in self.parameters.items(): self.OM_data_init += ', ' @@ -136,15 +129,8 @@ class UnitOperation(): self.OM_data_init += k + ' = ' + str(v) self.OM_data_init += ');\n' - - #print("HERE WE GO") - #print(self.OM_data_init) - return self.OM_data_init - - - def OM_Flowsheet_Equation(self): self.OM_data_eqn = '' @@ -190,7 +176,6 @@ class Heater(UnitOperation): self.Pdel = Pdel self.Eff = Eff self.parameters = {'Pdel':self.Pdel, 'Eff':self.Eff} - # self.input_parameters = {'Pdel':self.Pdel, 'Eff':self.Eff} type(self).counter += 1 class Cooler(UnitOperation): @@ -214,7 +199,6 @@ class Cooler(UnitOperation): self.Pdel = Pdel self.Eff = Eff self.parameters = {'Pdel':self.Pdel, 'Eff':self.Eff} - # self.input_parameters = {'Pdel':self.Pdel, 'Eff':self.Eff} type(self).counter += 1 class AdiabaticCompressor(UnitOperation): @@ -236,10 +220,9 @@ class AdiabaticCompressor(UnitOperation): self.extra = ['AdiabaticCompressor'] self.ForNaming = ['AdiabaticCompressor'] self.ThermoPackReq = True - self.thermoPackage ="RaoultsLaw" + self.thermoPackage ="RaoultsLaw" self.Eff = Eff self.parameters = {'Eff':self.Eff} - # self.input_parameters = {"Eff":self.Eff,"thermoPackage":self.thermoPackage} type(self).counter += 1 class AdiabaticExpander(UnitOperation): @@ -264,7 +247,5 @@ class AdiabaticExpander(UnitOperation): self.thermoPackage ="RaoultsLaw" self.Eff = Eff self.parameters = {'Eff':self.Eff} - # self.input_parameters = {"Eff":self.Eff,"thermoPackage":self.thermoPackage} type(self).counter += 1 - - +
\ No newline at end of file diff --git a/container.py b/container.py index 8b47c05..6cfc689 100644 --- a/container.py +++ b/container.py @@ -10,19 +10,18 @@ from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsElli from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent import PyQt5.QtCore as QtCore import PyQt5.QtWidgets as QtWidgets -from dockWidget import dockWidget import datetime import itertools import json import pickle import os import sys -unitOp = [] +from Graphics import * + class Container(): - def __init__(self,msgbrowser): - #self.unitOp = [] + self.unitOp = [] self.thermoPackage = None self.compounds = None self.flowsheet = None @@ -33,6 +32,7 @@ class Container(): self.msg.setText("") self.opl=[] self.result=[] + self.graphics = Graphics(self.unitOp) def currentTime(self): now = datetime.datetime.now() @@ -65,24 +65,26 @@ class Container(): except Exception as e: print(e) - def addUnitOp(self,obj,scene,graphics): + @staticmethod + def addUnitOpObj(obj): + self.unitOp.append(obj) + + def addUnitOp(self,obj): box = None self.obj = obj - self.scene = scene - self.graphics = graphics + self.scene = self.graphics.getScene() box = self.graphics.createNodeItem(self.obj) self.scene.addItem(box) box.setPos(2500-30, 2500-30) - if(obj in unitOp): + if(obj in self.unitOp): pass else: - #self.unitOp.append(obj) - unitOp.append(obj) + self.unitOp.append(obj) self.msg.append("<span style=\"color:blue\">["+str(self.currentTime())+"]<b> "+obj.name+" </b>is instantiated .""</span>") def fetchObject(self,name): - for i in unitOp: + for i in self.unitOp: if(i.name==name): return i @@ -109,11 +111,10 @@ class Container(): print("SIMULATE") print(mode) self.compounds = compound_selected - #self.connection() self.flowsheet = Flowsheet() self.flowsheet.add_comp_list(self.compounds) print("######## connection master#########\n",self.conn) - for i in unitOp : + for i in self.unitOp : print("here",i) self.flowsheet.add_UnitOpn(i) @@ -54,18 +54,9 @@ class MainApp(QMainWindow,ui): # Creating instances of classes for the main app self.Container = Container(self.textBrowser) self.comp = componentSelector(self) - '''self.Container = self.graphics.getContainer(self.textBrowser) - self.comp = self.graphics.getComponentSelector()''' - # Setting up interactive canvas - '''self.scene = QGraphicsScene() - self.scene.setItemIndexMethod(QGraphicsScene.BspTreeIndex) - self.graphicsView.setScene(self.scene) - self.graphicsView.setMouseTracking(True) - self.graphicsView.keyPressEvent=self.deleteCall''' - self.graphics = Graphics() - self.scene = self.graphics.getScene() + self.scene = self.Container.graphics.getScene() self.graphicsView.setScene(self.scene) self.graphicsView.setMouseTracking(True) self.graphicsView.keyPressEvent=self.deleteCall @@ -113,7 +104,6 @@ class MainApp(QMainWindow,ui): self.actionTerminate.setShortcut('Ctrl+T') self.actionBinary_Phase_Envelope.triggered.connect(self.BinPhaseEnv) - ''' Handles all the buttons of different components. ''' @@ -176,7 +166,6 @@ class MainApp(QMainWindow,ui): def simulate(self,mode): self.thrd = threading.Thread(target=self.Container.simulate, args=(mode,)) self.thrd.start() - # self.Container.simulate(mode) self.dockWidget_2.show() self.res = resdockWidget(self.Container) self.addDockWidget(Qt.LeftDockWidgetArea, self.res) @@ -197,7 +186,6 @@ class MainApp(QMainWindow,ui): ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, 0) print('Exception raise (Thread termination) failure') - ''' Resets the zoom level to default scaling ''' @@ -234,22 +222,27 @@ class MainApp(QMainWindow,ui): self.obj = MaterialStream(CompNames=compound_selected) else: self.obj = eval(self.type)() - self.Container.addUnitOp(self.obj,self.scene,self.graphics) + self.Container.addUnitOp(self.obj) else: QMessageBox.about(self, 'Important', "Please Select Compounds first") self.comp.show() - ''' New is used to delete all the existing work. ''' def new(self): - l=self.scene.items() + for i in self.Container.unitOp: + type(i).counter = 1 + del self.Container + lst.clear() + self.Container = Container(self.textBrowser) compound_selected.clear() self.comp.tableWidget.setRowCount(0) - self.delete(l) + self.scene = self.Container.graphics.getScene() self.textBrowser.append("<span>["+str(self.currentTime())+"] <b>New</b> flowsheet is created ... </span>") - self.comp.show() + self.graphicsView.setScene(self.scene) + self.graphicsView.setMouseTracking(True) + self.graphicsView.keyPressEvent=self.deleteCall ''' Handels all the operations which will happen when delete button is pressed. @@ -258,6 +251,8 @@ class MainApp(QMainWindow,ui): try: if event.key() == QtCore.Qt.Key_Delete: l=self.scene.selectedItems() + for i in l: + eval(i.type).counter -= 1 self.delete(l) except Exception as e: print(e) @@ -266,9 +261,7 @@ class MainApp(QMainWindow,ui): Deletes the selected item from the canvas and also the objects created for that type. ''' - def delete(self,l): - # if isinstance(l,NodeItem): - # l = [l] + def delete(self,l): for item in l: self.scene.removeItem(item) if hasattr(item,'Input'): @@ -288,7 +281,7 @@ class MainApp(QMainWindow,ui): self.scene.removeItem(x.otherLine) del x.otherLine if hasattr(item,'obj'): - unitOp.remove(item.obj) + self.Container.unitOp.remove(item.obj) for k in list(self.Container.conn): if item.obj==k: del self.Container.conn[k] @@ -303,8 +296,9 @@ class MainApp(QMainWindow,ui): ''' def save(self): data = [] - for i in unitOp: + for i in self.Container.unitOp: data.append(i) + print(i.pos) data.append(compound_selected) print(data) @@ -313,8 +307,9 @@ class MainApp(QMainWindow,ui): fileName, _ = QFileDialog.getSaveFileName(self, "Save As", initialPath, "%s Files (*.%s);; All Files (*)" % (fileFormat.upper(), fileFormat)) - with open(fileName, 'wb') as f: #'saved_file.sim' - pickle.dump(data, f, pickle.HIGHEST_PROTOCOL) + if fileName != "": + with open(fileName, 'wb') as f: #'saved_file.sim' + pickle.dump(data, f, pickle.HIGHEST_PROTOCOL) ''' Function for loading previous saved canvas and simulation @@ -322,13 +317,16 @@ class MainApp(QMainWindow,ui): def open(self): fileFormat = 'sim' initialPath = QDir.currentPath() + 'untitled.' + fileFormat + fileName, _ = QFileDialog.getOpenFileName(self, "Open As", initialPath, "%s Files (*.%s);; All Files (*)" % (fileFormat.upper(), fileFormat)) - with open(fileName, 'rb') as f: - obj = pickle.load(f) - - self.graphics.loadCanvas(obj) + if fileName != "": + self.new() + + with open(fileName, 'rb') as f: + obj = pickle.load(f) + self.Container.graphics.loadCanvas(obj) def main(): app = QApplication(sys.argv) diff --git a/resDockWidget.py b/resDockWidget.py index 69485ea..52b86f8 100644 --- a/resDockWidget.py +++ b/resDockWidget.py @@ -86,7 +86,7 @@ class resdockWidget(QDockWidget,ui_dialog): def results(self): # Should be named as selecting object whose result is to be displayed self.nameType={} - for i in unitOp: + for i in self.Container.unitOp: #nameslist.append(i.name) self.nameType[i.name] = i.type self.comboBox.addItem(str(i.name))
\ No newline at end of file |