3 \page tui_page Using SALOME GUI python interface
6 The extended salome.py Python module provides \b sg variable, which gives access to some GUI functions.
8 \b Note, that this variable is not available if you use salome.py
9 Python module outside of the GUI desktop, i.e. without 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)
17 # get the active study ID
18 studyId = salome.sg.getActiveStudyId()
20 # get the active study name
21 studyName = salome.sg.getActiveStudyName()
23 # get the selected objects
24 selCount = salome.sg.SelectedCount() # the number of selected items
25 for i in range(selCount):
26 print salome.sg.getSelected(i) # print the entry ID of i-th selected item
30 # get the list of IDs of all selected objects
31 selected = salome.sg.getAllSelected()
33 # add an object to the selection
34 salome.sg.AddIObject("0:1:1:1") # "0:1:1:1" is an object ID
36 # remove an 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 the selection (set all objects unselected)
40 salome.sg.ClearIObjects()
42 # display an 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 an 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
66 # reset the current view
69 # get the component symbolic name by its user name
70 compName = salome.sg.getComponentName("Geometry") # compoName = "GEOM"
72 # get the component user name by its symbolic name
73 compName = salome.sg.getComponentUserName("SMESH") # compoName = "Mesh"