5 # Global variable to store Salome Workspace
9 # Communication with Salome : desktop, signal and slots
10 sgPyQt=SalomePyQt.SalomePyQt()
12 # LifeCycle and component PYHELLO
14 lifecycle = salome.lcc
16 pyhello=lifecycle.FindOrLoadComponent("FactoryServerPy", "PYHELLO")
18 def setWorkSpace(pyws):
20 print "setWorkSpace: ",pyws
23 def OnGUIEvent(commandID) :
24 print "PYHELLOGUI::OnGUIEvent::commandID,WORKSPACE= ",commandID,WORKSPACE
25 if dict_command.has_key(commandID):
27 r=dict_command[commandID](WORKSPACE)
32 print "Pas de commande associƩe a : ",commandID
37 def activeStudyChanged(ID):
38 print "activeStudyChanged: ",ID
40 def definePopup(theContext, theObject, theParent):
41 print "PYHELLOGUI --- definePopup: ",theContext,theObject,theParent
43 def customPopup(popup, theContext, theObject, theParent):
44 print "PYHELLOGUI --- customPopup: ",theContext,theObject,theParent
46 class MyDialog(qt.QDialog):
47 def __init__(self,parent=None, name=None, modal=0, flags=0):
48 qt.QDialog.__init__(self,parent, name, modal, flags)
49 self.vb = qt.QVBoxLayout(self, 8)
51 self.hb0 = qt.QHBox(self)
52 label=QLabel("Prenom",self.hb0)
53 self.entry=QLineEdit( self.hb0)
55 self.hb = qt.QHBox(self)
56 c = qt.QPushButton("OK", self.hb)
57 self.connect(c, qt.SIGNAL('clicked()'), self, SLOT('accept()'))
58 d = qt.QPushButton("CANCEL", self.hb)
59 self.connect(d, qt.SIGNAL('clicked()'), self, SLOT('reject()'))
62 # Modal dialog, parent desktop
63 desktop=sgPyQt.getDesktop()
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)