16 def __init__(self,parent,proc):
17 QVBox.__init__(self,parent)
18 self.hSplitter = QSplitter(self,"hSplitter")
19 self.objectBrowser=Tree.Tree(self.hSplitter,self.onSelect)
20 pp=adapt.adapt(proc,Item.Item)
23 self.objectBrowser.additem(pp)
24 self.panelManager=PanelManager.PanelManager(self.hSplitter)
29 def onSelect(self,item):
30 #item is instance of Item.Item
32 self.panelManager.setview(item)
36 self.executor = pilot.ExecutorSwig()
37 if self.thr and self.thr.isAlive():
39 #step by step execution mode
40 self.executor.setExecMode(1)
41 #execute it in a thread
42 self.thr = threading.Thread(target=self.executor.RunW, args=(self.proc,0))
43 #as a daemon (no need to join)
50 self.executor.waitPause()
51 #switch to continue execution mode
52 self.executor.setExecMode(0)
54 self.executor.resumeCurrentBreakPoint()
58 """Suspend or resume an executing schema"""
61 if not self.thr.isAlive():
65 #continue execution mode
66 self.executor.setExecMode(0)
69 self.executor.resumeCurrentBreakPoint()
72 #step by step execution mode
73 self.executor.setExecMode(1)
74 #self.executor.waitPause()
78 """Step on a paused schema"""
80 self.executor = pilot.ExecutorSwig()
81 if not self.thr or not self.thr.isAlive():
82 #start in step by step mode
83 self.executor.setExecMode(1)
84 self.thr = threading.Thread(target=self.executor.RunW, args=(self.proc,0))
90 #step by step execution mode
92 self.executor.setExecMode(1)
95 self.executor.resumeCurrentBreakPoint()
101 if not self.thr.isAlive():
103 self.executor.setExecMode(1)
104 self.executor.waitPause()
105 self.executor.resumeCurrentBreakPoint()
106 #self.executor.stopExecution()
108 class Appli(QMainWindow):
111 Cree la fenetre principale de l'interface utilisateur
114 QMainWindow.__init__(self)
122 def createWidgets(self):
123 self.tabWidget = QTabWidget(self)
124 self.currentPanel=None
125 self.connect(self.tabWidget, SIGNAL('currentChanged(QWidget *)'),self.handlePanelChanged)
126 self.setCentralWidget(self.tabWidget)
129 def handlePanelChanged(self,panel):
130 self.currentPanel=panel
132 def initActions(self):
135 self.newAct=QAction('New', QIconSet(Icons.get_image("new")), '&New',
136 QKeySequence("CTRL+N"),self)
137 self.newAct.setStatusTip('Open an empty editor window')
138 self.newAct.setWhatsThis( """<b>New</b>"""
139 """<p>An empty editor window will be created.</p>""")
140 self.newAct.connect(self.newAct,SIGNAL('activated()'), self.handleFile)
141 self.actions.append(self.newAct)
143 self.prefAct=QAction('Preferences',QIconSet(Icons.get_image("configure.png")),'&Preferences...',
145 self.prefAct.setStatusTip('Set the prefered configuration')
146 self.prefAct.setWhatsThis("""<b>Preferences</b>"""
147 """<p>Set the configuration items of the application"""
148 """ with your prefered values.</p>""")
149 self.prefAct.connect(self.prefAct,SIGNAL('activated()'), self.handlePreferences)
150 self.actions.append(self.prefAct)
152 self.runAct=QAction('Run',QIconSet(Icons.get_image("run.png")),'&Run',0,self)
153 self.runAct.connect(self.runAct,SIGNAL('activated()'), self.run)
154 self.runAct.setStatusTip('Run the selected schema')
155 self.actions.append(self.runAct)
157 self.suspAct=QAction('Suspend/resume',QIconSet(Icons.get_image("suspend-resume.gif")),'&Suspend/resume',0,self)
158 self.suspAct.connect(self.suspAct,SIGNAL('activated()'), self.susp)
159 self.suspAct.setStatusTip('Suspend/resume the selected schema')
160 self.actions.append(self.suspAct)
162 self.stepAct=QAction('Step',QIconSet(Icons.get_image("steps.png")),'&Step',0,self)
163 self.stepAct.connect(self.stepAct,SIGNAL('activated()'), self.step)
164 self.stepAct.setStatusTip('Step the selected schema')
165 self.actions.append(self.stepAct)
167 self.stopAct=QAction('Stop',QIconSet(Icons.get_image("kill.png")),'&Stop',0,self)
168 self.stopAct.connect(self.stopAct,SIGNAL('activated()'), self.stop)
169 self.stopAct.setStatusTip('Stop the selected schema')
170 self.actions.append(self.stopAct)
173 menubar = self.menuBar()
176 self.fileMenu=QPopupMenu(self)
177 self.newAct.addTo(self.fileMenu)
178 self.fileMenu.insertItem("&Open", self.openFile)
179 self.fileMenu.insertItem("&Open Salome", self.openSalomeFile)
180 menubar.insertItem('&File',self.fileMenu)
183 self.settingsMenu = QPopupMenu(self)
184 menubar.insertItem('&Settings', self.settingsMenu)
185 self.settingsMenu.insertTearOffHandle()
186 self.prefAct.addTo(self.settingsMenu)
189 self.editMenu = QPopupMenu(self)
190 self.editMenu.insertItem("&Add node", self.addNode)
191 menubar.insertItem('&Edit', self.editMenu)
195 self.layoutMenu = QPopupMenu(self)
196 self.layoutMenu.insertItem("&Left Right", self.LR)
197 self.canvasMenu = QPopupMenu(self)
198 self.canvasMenu.insertItem("&Zoom in", self.zoomIn)
199 self.canvasMenu.insertItem("Zoom &out", self.zoomOut)
200 self.canvasMenu.insertItem("Layout", self.layoutMenu)
201 self.canvasMenu.insertItem("&Update", self.updateCanvas)
202 menubar.insertItem('&Canvas', self.canvasMenu)
205 self.windowMenu = QPopupMenu(self)
206 menubar.insertItem('&Window', self.windowMenu)
207 self.connect(self.windowMenu, SIGNAL('aboutToShow()'), self.handleWindowMenu)
210 self.help=QPopupMenu(self)
211 menubar.insertItem('&Help',self.help)
212 self.help.insertItem('&About',self.about,Qt.Key_F1)
213 self.help.insertItem('About &Qt',self.aboutQt)
219 self.runtime= pilot.getRuntime()
220 self.loader = loader.YACSLoader()
221 self.executor = pilot.ExecutorSwig()
222 self.salomeloader=salomeloader.SalomeLoader()
224 def openSalomeFile(self):
225 fn = QFileDialog.getOpenFileName(QString.null,QString.null,self)
227 self.statusBar().message('Loading aborted',2000)
230 proc=self.salomeloader.load(fileName)
232 panel=Browser(self.tabWidget,proc)
233 self.currentPanel=panel
234 self.tabWidget.addTab( panel,os.path.basename(fileName))
235 self.tabWidget.showPage(panel)
238 fn = QFileDialog.getOpenFileName(QString.null,QString.null,self)
240 self.statusBar().message('Loading aborted',2000)
243 proc=self.loader.load(fileName)
245 panel=Browser(self.tabWidget,proc)
246 self.currentPanel=panel
247 self.tabWidget.addTab( panel,os.path.basename(fileName))
248 self.tabWidget.showPage(panel)
251 if self.currentPanel.selected and isinstance(self.currentPanel.selected,Items.ItemComposedNode):
252 self.currentPanel.selected.layout("LR")
254 def updateCanvas(self):
255 if self.currentPanel.selected:#item selected
256 if isinstance(self.currentPanel.selected,Items.ItemComposedNode):
258 self.currentPanel.selected.editor.updateCanvas()
261 if self.currentPanel.selected:#item selected
262 if isinstance(self.currentPanel.selected,Items.ItemComposedNode):
263 #on peut ajouter un noeud
264 self.currentPanel.selected.addNode()
267 if self.currentPanel.selected:#item selected
268 if isinstance(self.currentPanel.selected,Items.ItemComposedNode):
270 self.currentPanel.selected.editor.zoomIn()
273 if self.currentPanel.selected:#item selected
274 if isinstance(self.currentPanel.selected,Items.ItemComposedNode):
276 self.currentPanel.selected.editor.zoomOut()
278 def handleFile(self):
281 def handlePreferences(self):
284 def handleWindowMenu(self):
288 QMessageBox.about(self,'YACS browser GUI', 'YACS browser GUI')
291 QMessageBox.aboutQt(self,'YACS browser GUI')
294 if self.currentPanel:
295 self.currentPanel.run()
298 if self.currentPanel:
299 self.currentPanel.susp()
302 if self.currentPanel:
303 self.currentPanel.step()
306 if self.currentPanel:
307 self.currentPanel.stop()
309 def initToolbar(self):
311 self.newAct.addTo(tb)
312 self.runAct.addTo(tb)
313 self.suspAct.addTo(tb)
314 self.stepAct.addTo(tb)
315 self.stopAct.addTo(tb)
317 self.toolbars['File']=tb
319 def initStatusbar(self):
320 sb = self.statusBar()
321 self.SBfile=QLabel(sb)
322 sb.addWidget(self.SBfile)
323 QWhatsThis.add(self.SBfile,
324 """<p>Partie de la statusbar qui donne le nom"""
325 """du fichier courant. </p>""")
326 self.SBfile.setText("")
329 if __name__ == "__main__":
330 from Item import Item
331 app = QApplication(sys.argv)
333 t.objectBrowser.additem(Item("item1"))
334 n=t.objectBrowser.additem(Item("item2"))
335 n.additem(Item("item3"))