Browse Source

support unicode types transparently

David Rose 20 years ago
parent
commit
1d72ba0f7e
2 changed files with 6 additions and 5 deletions
  1. 5 4
      direct/src/gui/DirectFrame.py
  2. 1 1
      direct/src/gui/DirectGuiBase.py

+ 5 - 4
direct/src/gui/DirectFrame.py

@@ -44,13 +44,14 @@ class DirectFrame(DirectGuiWidget):
         # Determine if user passed in single string or a sequence
         # Determine if user passed in single string or a sequence
         if self['text'] == None:
         if self['text'] == None:
             textList = (None,) * self['numStates']
             textList = (None,) * self['numStates']
-        elif type(self['text']) == types.StringType:
+        elif isinstance(self['text'], types.StringTypes):
             # If just passing in a single string, make a tuple out of it
             # If just passing in a single string, make a tuple out of it
             textList = (self['text'],) * self['numStates']
             textList = (self['text'],) * self['numStates']
         else:
         else:
             # Otherwise, hope that the user has passed in a tuple/list
             # Otherwise, hope that the user has passed in a tuple/list
             textList = self['text']
             textList = self['text']
         # Create/destroy components
         # Create/destroy components
+        print "textList = %s" % (textList,)
         for i in range(self['numStates']):
         for i in range(self['numStates']):
             component = 'text' + `i`
             component = 'text' + `i`
             # If fewer items specified than numStates,
             # If fewer items specified than numStates,
@@ -125,14 +126,14 @@ class DirectFrame(DirectGuiWidget):
             imageList = (None,) * self['numStates']
             imageList = (None,) * self['numStates']
         elif isinstance(arg, NodePath):
         elif isinstance(arg, NodePath):
             imageList = (arg,) * self['numStates']
             imageList = (arg,) * self['numStates']
-        elif type(arg) == types.StringType:
+        elif isinstance(arg, types.StringTypes):
             # Passed in a single node path, make a tuple out of it
             # Passed in a single node path, make a tuple out of it
             imageList = (arg,) * self['numStates']
             imageList = (arg,) * self['numStates']
         else:
         else:
             # Otherwise, hope that the user has passed in a tuple/list
             # Otherwise, hope that the user has passed in a tuple/list
             if ((len(arg) == 2) and
             if ((len(arg) == 2) and
-                (type(arg[0]) == types.StringType) and
-                (type(arg[1]) == types.StringType)):
+                isinstance(arg[0], types.StringTypes) and
+                isinstance(arg[1], types.StringTypes)):
                 # Its a model/node pair of strings
                 # Its a model/node pair of strings
                 imageList = (arg,) * self['numStates']
                 imageList = (arg,) * self['numStates']
             else:
             else:

+ 1 - 1
direct/src/gui/DirectGuiBase.py

@@ -924,7 +924,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
         # Convert None, and string arguments
         # Convert None, and string arguments
         if relief == None:
         if relief == None:
             relief = PGFrameStyle.TNone
             relief = PGFrameStyle.TNone
-        elif type(relief) == types.StringType:
+        elif isinstance(relief, types.StringTypes):
             # Convert string to frame style int
             # Convert string to frame style int
             relief = FrameStyleDict[relief]
             relief = FrameStyleDict[relief]
         # Set style
         # Set style