def __loadFile(self, _file): if _file == None: return old_Controller = self.mainController self.mainController = PyLinXProjectController.PyLinXProjectController( mainWindow=self) # TODO: should be removed in the long term self.ui.drawWidget.newProject(self.mainController) self.ui.TabWidget.newProject(self.mainController) _file_read = _file.read() self.mainController.execScript(_file_read) old_Controller.delete() self.ui.repaint()
super(PX_Tab_Recorder, self).repaint() def addListWidgetItem(self, listItemName=None): if listItemName == None: listItemName = 'Item ' + str(len(self.listItems.keys())) self.listItems[listItemName] = None self.rebuildListWidget() def newProject(self, mainController): self.mainController = mainController self.__objectHandler = mainController.getb(u"ObjectHandler") if __name__ == '__main__': app = QtGui.QApplication(sys.argv) mainController = ctl.PyLinXProjectController(bListActions=False) # Example-Data script = u"new varElement TestVar_0 150 90 15 refName=\"TestVar_0\"\n\ new varElement Variable_id4 150 140 15 refName=\"Variable_id4_1\" \n\ new varElement Variable_id4 400.0 100.0 15 refName=\"Variable_id4_2\"\n\ new basicOperator + 300.0 100.0 name=u\"Operator_1\"\n\ new connector TestVar_0 Operator_1 idxInPin=1\n\ new connector Variable_id4_1 Operator_1 idxInPin=0\n\ new connector Operator_1 Variable_id4_2 idxInPin=0" mainController.execScript(script) dialog_1 = PX_Tab_Recorder(mainController) dialog_1.show()
def __init__(self): super(PyLinXMain, self).__init__() # Loading ui-file uiString = u".//Recources//Ui//PyLinX_v0_5.ui" self.ui = uic.loadUi(uiString) reload(sys) sys.setdefaultencoding('utf8') self.runThreadMessageQueue = Queue.Queue() #QtGui.QApplication.setStyle( QtGui.QStyleFactory.create('cleanlooks') ) #QtGui.QApplication.setStyle( QtGui.QStyleFactory.create('plastique') ) #QtGui.QApplication.setStyle( QtGui.QStyleFactory.create('motif') ) #QtGui.QApplication.setStyle( QtGui.QStyleFactory.create('cde') ) # Main Data Structures #self.mainController = PyLinXCtl.PyLinXProjectController.PyLinXProjectController(mainWindow = self ) self.mainController = PyLinXProjectController.PyLinXProjectController( mainWindow=self) _rootGraphics = self.mainController.getb(u"rootGraphics") # run Engine self.runEngine = None # Events self.stopRunEvent = threading.Event() self.repaintEvent = threading.Event() ########################## # Building the main Window ########################## # Decoration self.ui.setWindowIcon(QtGui.QIcon(r"icons/pylinx_16.png")) self.ui.setWindowTitle('PyLinX') # ScrollArea self.ui.scrollingArea = QtGui.QScrollArea() self.ui.scrollingArea.setAutoFillBackground(False) # DrawWidget self.ui.drawWidget = PX_Widget_MainDrawArea.DrawWidget( self.mainController, self, self.repaintEvent) ############ # TabWidget ############ self.ui.TabWidget = PX_TabWidget_main.PX_TabWidget_main( mainController=self.mainController) self.ui.TabWidget.setMinimumWidth(260) # Info self.ui.TabInfo = QtGui.QWidget() self.ui.TabWidget.adjoinTab( self.ui.TabInfo, u"Info", PX_TabWidget_main.PX_TabWidget_main. DisplayRole.inEditAndSimulationMode, 1) # Signals self.ui.TabSignals = PX_Tab_SignalSelect.PX_Tab_SignalSelect( self.mainController, drawWidget=self.ui.drawWidget) self.ui.TabWidget.adjoinTab( self.ui.TabSignals, u"Signals", PX_TabWidget_main. PX_TabWidget_main.DisplayRole.onlyInSimulationMode, 2) # Elements self.ui.TabElements = PX_Tab_ObjectHandlerList.PX_Tab_ObjectHandlerList( self.mainController) self.ui.TabWidget.adjoinTab( self.ui.TabElements, u"Elements", PX_TabWidget_main.PX_TabWidget_main.DisplayRole.onlyInEditMode, 3) # Recorder self.ui.Tabrecorder = PX_Tab_Recorder.PX_Tab_Recorder( self.mainController) self.ui.TabWidget.adjoinTab( self.ui.Tabrecorder, u"Recorder", PX_TabWidget_main. PX_TabWidget_main.DisplayRole.onlyInSimulationMode, 4) #Connect Signal self.connect(self, QtCore.SIGNAL("updateTabs"), self.ui.TabWidget.updateTabs) # Splitter self.ui.splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) self.ui.splitter1.addWidget(self.ui.TabWidget) self.ui.splitter1.addWidget(self.ui.scrollingArea) self.ui.splitter1.setStretchFactor(1, 4) self.ui.splitter1.setStretchFactor(0, 1) self.ui.splitter1.setStyleSheet(""" .QSplitter { padding-left: 8px; padding-top: 8px; padding-right: 8px; } """) # Connecting ScrollingArea and DrawingArea self.ui.scrollingArea.setWidget(self.ui.drawWidget) # Set central Widget self.ui.setCentralWidget(self.ui.splitter1) #################### # Connecting Signals #################### self.connect(self.ui.drawWidget, QtCore.SIGNAL(u"signal_repaint_Tab_SignalSelect"), self.ui.TabSignals.repaint) # Menu-Bar # Programm self.ui.actionClose.triggered.connect(self.closeApplication) # Project self.ui.actionNewProject.triggered.connect(self.on_actionNewProject) self.ui.actionLoadProject.triggered.connect(self.on_actionLoadProject) self.ui.actionSave.triggered.connect(self.on_actionSave) self.ui.actionSave_As.triggered.connect(self.on_actionSave_As) # Tool-Bar self.ui.actionNewElement.triggered.connect(self.on_actionNewElement) self.ui.actionNewElement.setCheckable(True) self.ui.actionNewPlus.triggered.connect(self.on_actionNewPlus) self.ui.actionNewMinus.triggered.connect(self.on_actionNewMinus) self.ui.actionNewMultiplication.triggered.connect( self.on_actionNewMultiplication) self.ui.actionNewDivision.triggered.connect(self.on_actionNewDivision) self.ui.actionNewPlus.setCheckable(True) self.ui.actionNewMinus.setCheckable(True) self.ui.actionNewMultiplication.setCheckable(True) self.ui.actionNewDivision.setCheckable(True) self.ui.actionRun.setEnabled(False) self.ui.actionActivate_Simulation_Mode.triggered.connect( self.on_Activate_Simulation_Mode) # The order of cennoction will determine the order of calls self.ui.actionRun.triggered.connect(self.ui.Tabrecorder.runInit) self.ui.actionRun.triggered.connect(self.on_run) self.ui.actionStop.triggered.connect(self.on_stop) # Configurations that require the GUI to exist #self.mainController.set(u"bSimulationMode", False) self.mainController.bSimulationMode = False ################ # ExampleData ################ _file = open( r"D:\Projekte\PyLinX\Aptana-Projekte\PyLinX2\Recources\Testdata\testProjekt_setUeberarbeitung.pyp" ) #_file = open(r"D:\Projekte\PyLinX\Aptana-Projekte\PyLinX2\Recources\TestCases\testCase_Bug_GetNeu.pyp") self.__loadFile(_file) script = u"new varElement TestVar_0 150 90 15 refName=\"TestVar_0\"\n\ new varElement Variable_id4 150 140 15 refName=\"Variable_id4_1\" \n\ new varElement Variable_id4 400.0 100.0 15 refName=\"Variable_id4_2\"\n\ new basicOperator + 300.0 100.0 name=u\"Operator_1\"\n\ new connector TestVar_0 Operator_1 idxInPin=-1\n\ new connector Variable_id4_1 Operator_1 idxInPin=-2\n\ new connector Operator_1 Variable_id4_2 idxInPin=-1" #self.mainController.execScript(script) ############ # Finish ############ # Show GUI self.ui.resize(800, 600) self.ui.show()