support unicode types transparently

This commit is contained in:
David Rose 2005-07-13 23:05:35 +00:00
parent 9c433e2013
commit 1d72ba0f7e
2 changed files with 6 additions and 5 deletions

View File

@ -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 isinstance(arg[0], types.StringTypes) and
(type(arg[1]) == types.StringType)): 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:

View File

@ -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