3 \page tui_page Using SALOME GUI python interface
6 The extended salome.py Python module provides a \b sg variable, this variable provides an access to some GUI functions.
8 \b Note, that this variable is not available if you use salome.py
9 Python module outside the GUI desktop, i.e. not in the embedded Python
10 console (since SWIG library is linked directly to the GUI library).
14 # update Object browser contents
15 salome.sg.updateObjBrowser(True)
18 studyId = salome.sg.getActiveStudyId()
20 # get active study name
21 studyName = salome.sg.getActiveStudyName()
23 # get selected objects
24 selCount = salome.sg.SelectedCount() # total number of selected items
25 for i in range(selCount):
26 print salome.sg.getSelected(i) # print entry ID of i-th selected item
30 # get list of all selected objects' IDs
31 selected = salome.sg.getAllSelected()
33 # add object to the selection
34 salome.sg.AddIObject("0:1:1:1") # "0:1:1:1" is an object ID
36 # remove object from the selection (make it unselected)
37 salome.sg.RemoveIObject("0:1:1:1") # "0:1:1:1" is an object ID
39 # clear selection (set all objects unselected)
40 salome.sg.ClearIObjects()
42 # display object in the current view (if possible)
43 salome.sg.Display("0:1:1:1") # "0:1:1:1" is an object ID
44 salome.sg.UpdateView() # update view
46 # erase object from the current view
47 salome.sg.Erase("0:1:1:1") # "0:1:1:1" is an object ID
48 salome.sg.UpdateView() # update view
50 # display all objects in the current view (if possible)
51 salome.sg.DisplayAll()
52 salome.sg.UpdateView() # update view
54 # erase all objects from the current view
56 salome.sg.UpdateView() # update view
58 # set top, bottom, front, rear, left, right view
59 salome.sg.ViewTop() # top view
60 salome.sg.ViewBottom() # bottom view
61 salome.sg.ViewFront() # front view
62 salome.sg.ViewTop() # back view
63 salome.sg.ViewLeft() # left view
64 salome.sg.ViewRight() # right view
69 # get component symbolic name by its user name
70 compName = salome.sg.getComponentName("Geometry") # compoName = "GEOM"
72 # get component user name by its symbolic name
73 compName = salome.sg.getComponentUserName("SMESH") # compoName = "Mesh"