]> SALOME platform Git repositories - samples/pyhello.git/blobdiff - src/PYHELLOGUI/PYHELLOGUI.py
Salome HOME
NPAL15833: EDF406: Save icon is inactive when study is modified.
[samples/pyhello.git] / src / PYHELLOGUI / PYHELLOGUI.py
index 79201a6dd795e525ce3a85b330fbe845a576182e..8144c35630ca1639e30e7c9f74a24f13c9e6a4ef 100644 (file)
@@ -1,3 +1,21 @@
+#  Copyright (C) 2005  CEA/DEN, EDF R&D
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 from qt import *
 import traceback
 
@@ -123,15 +141,18 @@ def definePopup( context, object, parent ):
 # customize popup menu
 def customPopup( popup, context, object, parent ):
     print "PYHELLOGUI::customPopup :", context, object, parent
-    id = int( object )
-    if id == __MODULE_ID__:
-        study = _getStudy()
-        if sg.SelectedCount() == 1:
-            entry = sg.getSelected( 0 )
-            if entry != '':
-                sobj = study.FindObjectID( entry )
-                if sobj and not _hasChildren( sobj ):
-                    popup.removeItem( 951 ) # remove 'Delete All' command
+    try:
+        id = int( object )
+        if id == __MODULE_ID__:
+            study = _getStudy()
+            if sg.SelectedCount() == 1:
+                entry = sg.getSelected( 0 )
+                if entry != '':
+                    sobj = study.FindObjectID( entry )
+                    if sobj and not _hasChildren( sobj ):
+                        popup.removeItem( 951 ) # remove 'Delete All' command
+    except:
+        pass
     pass
 
 # process GUI action
@@ -204,7 +225,7 @@ def CreateObject():
     attr.SetValue( "Object " +  str( __id__ ) )
     attr    = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
     attr.SetValue( __OBJECT_ID__ )
-    sgPyQt.updateObjBrowser()
+    sg.updateObjBrowser(True)
     pass
 
 # ----------------------- #
@@ -218,7 +239,7 @@ def DeleteAll():
             sobj = iter.Value()
             iter.Next()
             builder.RemoveObjectWithChildren( sobj )
-        sgPyQt.updateObjBrowser()
+        sg.updateObjBrowser(True)
     pass
 
 # ----------------------- #
@@ -243,7 +264,7 @@ def Delete():
         if ( sobj ):
             builder = study.NewBuilder()
             builder.RemoveObject( sobj )
-            sgPyQt.updateObjBrowser()
+            sg.updateObjBrowser(True)
     pass
 
 # ----------------------- #