Back to index

salome-gui  6.5.0
Functions | Variables
GUI_PY.helper Namespace Reference

Functions

def getActiveStudy
def getSObjectSelected
def showSObjectSelected
def deleteSObjectSelected
def TEST_getSObjectSelected
def TEST_showSObjectSelected

Variables

tuple sgPyQt = SalomePyQt.SalomePyQt()
tuple SalomeGUI = libSALOME_Swig.SALOMEGUI_Swig()

Function Documentation

This function deletes the selected object.

Definition at line 109 of file helper.py.

00109 
00110 def deleteSObjectSelected(): 
00111     '''
00112     This function deletes the selected object.
00113     '''
00114     sobj, entry = getSObjectSelected()
00115     if ( sobj ):
00116         study = getActiveStudy()
00117         builder = study.NewBuilder()
00118         builder.RemoveObject( sobj )
00119         SalomeGUI.updateObjBrowser(True)
00120     pass
00121 
00122 #
00123 # ==================================================================
00124 # Use cases and demo functions
00125 # ==================================================================
00126 #
00127 
00128 # CAUTION: Before running this test functions, you first have to
00129 # create (or import) an object and select this object in the objects
00130 # browser.
00131 
00132 #
00133 # Definitions:
00134 # - the SObject is an item in the active study (Study Object).
00135 # - the entry is the identifier of an item.
00136 # - the object (geom object or smesh object) is a CORBA servant
00137 #   embedded in the SALOME component container and with a reference in
00138 #   the SALOME study, so that it can be retrieved.
00139 #

Here is the call graph for this function:

This returns a study object that corresponds to the active
study. The active study is a GUI concept: it's the study currently
active on the desktop.

Definition at line 63 of file helper.py.

00063 
00064 def getActiveStudy():
00065     """
00066     This returns a study object that corresponds to the active
00067     study. The active study is a GUI concept: it's the study currently
00068     active on the desktop.
00069     """
00070     studyId = sgPyQt.getStudyId()
00071     study = services.getStudyManager().GetStudyByID( studyId )
00072     return study
00073 
00074 #
00075 # ==================================================================
00076 # Functions to manipulate the objects in the browser (generic)
00077 # ==================================================================
#

Here is the caller graph for this function:

Returns the sobject and the entry of the item currently selected
in the objects browser. Returns "None, None" if no item is
selected. If several objects are selected, it returns the first
one of the list.

Definition at line 78 of file helper.py.

00078 
00079 def getSObjectSelected():
00080     '''
00081     Returns the sobject and the entry of the item currently selected
00082     in the objects browser. Returns "None, None" if no item is
00083     selected. If several objects are selected, it returns the first
00084     one of the list.
00085     '''
00086     sobj = None
00087     entry = None
00088     study = getActiveStudy()
00089     if SalomeGUI.SelectedCount() == 1:
00090         # We only considere the first element of the list. If you need
00091         # something else, create another function in your own context.
00092         entry = SalomeGUI.getSelected( 0 )
00093         if entry != '':
00094             sobj = study.FindObjectID( entry )
00095     return sobj, entry

Here is the call graph for this function:

Here is the caller graph for this function:

This function print the attributes of the selected object.
(this function is  only for test purpose)

Definition at line 96 of file helper.py.

00096 
00097 def showSObjectSelected():
00098     '''
00099     This function print the attributes of the selected object.
00100     (this function is  only for test purpose)
00101     '''
00102     sobj, entry = getSObjectSelected()
00103     if ( sobj ):
00104         test, attr = sobj.FindAttribute( "AttributeName" )
00105         if test:
00106             message = "My name is '%s'" % attr.Value()
00107             print message
00108     pass

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file helper.py.

00140 
00141 def TEST_getSObjectSelected():
00142     mySObject, myEntry = getSObjectSelected()
00143     myName = mySObject.GetName()
00144     print "The name of the selected object is %s"%myName

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 145 of file helper.py.

Here is the call graph for this function:


Variable Documentation

Definition at line 54 of file helper.py.

tuple GUI_PY.helper.sgPyQt = SalomePyQt.SalomePyQt()

Definition at line 48 of file helper.py.