The extended salome.py Python module provides a sg variable, this variable provides an access to some GUI functions.
Note, that this variable is not available if you use salome.py Python module outside the GUI desktop, i.e. not in the embedded Python console (since SWIG library is linked directly to the GUI library).
The example of usage:
# update Object browser contents salome.sg.updateObjBrowser(True) # get active study ID studyId = salome.sg.getActiveStudyId() # get active study name studyName = salome.sg.getActiveStudyName() # get selected objects selCount = salome.sg.SelectedCount() # total number of selected items for i in range(selCount): print salome.sg.getSelected(i) # print entry ID of i-th selected item
# get list of all selected objects' IDs selected = salome.sg.getAllSelected() # add object to the selection salome.sg.AddIObject("0:1:1:1") # "0:1:1:1" is an object ID # remove object from the selection (make it unselected) salome.sg.RemoveIObject("0:1:1:1") # "0:1:1:1" is an object ID # clear selection (set all objects unselected) salome.sg.ClearIObjects() # display object in the current view (if possible) salome.sg.Display("0:1:1:1") # "0:1:1:1" is an object ID salome.sg.UpdateView() # update view # erase object from the current view salome.sg.Erase("0:1:1:1") # "0:1:1:1" is an object ID salome.sg.UpdateView() # update view # display all objects in the current view (if possible) salome.sg.DisplayAll() salome.sg.UpdateView() # update view # erase all objects from the current view salome.sg.EraseAll() salome.sg.UpdateView() # update view # set top, bottom, front, rear, left, right view salome.sg.ViewTop() # top view salome.sg.ViewBottom() # bottom view salome.sg.ViewFront() # front view salome.sg.ViewTop() # back view salome.sg.ViewLeft() # left view salome.sg.ViewRight() # right view # reset current view salome.sg.ResetView() # get component symbolic name by its user name compName = salome.sg.getComponentName("Geometry") # compoName = "GEOM" # get component user name by its symbolic name compName = salome.sg.getComponentUserName("SMESH") # compoName = "Mesh" # ...