5 # Global variable to store Salome Workspace
9 # Communication with Salome : desktop, signal and slots
10 sgPyQt=SalomePyQt.SalomePyQt()
11 desktop=sgPyQt.getDesktop()
13 # LifeCycle and component PYHELLO
15 lifecycle = salome.lcc
17 pyhello=lifecycle.FindOrLoadComponent("FactoryServerPy", "PYHELLO")
19 def setWorkSpace(pyws):
21 print "setWorkSpace: ",pyws
24 def OnGUIEvent(commandID) :
25 print "PYHELLOGUI::OnGUIEvent::commandID,WORKSPACE= ",commandID,WORKSPACE
26 if dict_command.has_key(commandID):
28 r=dict_command[commandID](WORKSPACE)
33 print "Pas de commande associée a : ",commandID
38 def activeStudyChanged(ID):
39 print "activeStudyChanged: ",ID
41 def definePopup(theContext, theObject, theParent):
42 print "PYHELLOGUI --- definePopup: ",theContext,theObject,theParent
44 def customPopup(popup, theContext, theObject, theParent):
45 print "PYHELLOGUI --- customPopup: ",theContext,theObject,theParent
47 class MyDialog(qt.QDialog):
48 def __init__(self,parent=None, name=None, modal=0, flags=0):
49 qt.QDialog.__init__(self,parent, name, modal, flags)
50 self.vb = qt.QVBoxLayout(self, 8)
52 self.hb0 = qt.QHBox(self)
53 label=QLabel("Prenom",self.hb0)
54 self.entry=QLineEdit( self.hb0)
56 self.hb = qt.QHBox(self)
57 c = qt.QPushButton("OK", self.hb)
58 self.connect(c, qt.SIGNAL('clicked()'), self.accept)
59 d = qt.QPushButton("CANCEL", self.hb)
60 self.connect(d, qt.SIGNAL('clicked()'), self.reject)
63 # Modal dialog, parent desktop
64 w=MyDialog(desktop,"Name",1)
67 if r == QDialog.Accepted:
68 name=str(w.entry.text())
69 banner=pyhello.makeBanner(name)
70 QMessageBox.about(desktop,'Salome Example',banner)