Browse Source

Added option to make item uneditable

Gyedo Jeon 18 years ago
parent
commit
fff43ee097
1 changed files with 4 additions and 3 deletions
  1. 4 3
      direct/src/tkwidgets/SceneGraphExplorer.py

+ 4 - 3
direct/src/tkwidgets/SceneGraphExplorer.py

@@ -27,7 +27,7 @@ DEFAULT_MENU_ITEMS = [
 
 
 class SceneGraphExplorer(Pmw.MegaWidget, DirectObject):
 class SceneGraphExplorer(Pmw.MegaWidget, DirectObject):
     "Graphical display of a scene graph"
     "Graphical display of a scene graph"
-    def __init__(self, parent = None, nodePath = render, **kw):
+    def __init__(self, parent = None, nodePath = render, isItemEditable = True, **kw):
         # Define the megawidget options.
         # Define the megawidget options.
         optiondefs = (
         optiondefs = (
             ('menuItems',   [],   Pmw.INITOPT),
             ('menuItems',   [],   Pmw.INITOPT),
@@ -145,8 +145,9 @@ class SceneGraphExplorerItem(TreeItem):
 
 
     """Example TreeItem subclass -- browse the file system."""
     """Example TreeItem subclass -- browse the file system."""
 
 
-    def __init__(self, nodePath):
+    def __init__(self, nodePath, isItemEditable = True):
         self.nodePath = nodePath
         self.nodePath = nodePath
+        self.isItemEditable = isItemEditable
 
 
     def GetText(self):
     def GetText(self):
         type = self.nodePath.node().getType().getName()
         type = self.nodePath.node().getType().getName()
@@ -158,7 +159,7 @@ class SceneGraphExplorerItem(TreeItem):
 
 
     def IsEditable(self):
     def IsEditable(self):
         # All nodes' names can be edited nowadays.
         # All nodes' names can be edited nowadays.
-        return 1
+        return self.isItemEditable
         #return issubclass(self.nodePath.node().__class__, NamedNode)
         #return issubclass(self.nodePath.node().__class__, NamedNode)
 
 
     def SetText(self, text):
     def SetText(self, text):