Changeset 8125 for trunk/anuga_core/source/anuga/pmesh/Pmw.py
- Timestamp:
- Mar 4, 2011, 2:34:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/pmesh/Pmw.py
r8124 r8125 241 241 242 242 # Allow an attribute name (String) or a function to determine the instance 243 if type(toPart) != types.StringType:243 if not isinstance(toPart, basestring): 244 244 245 245 # check that it is something like a function … … 279 279 for method, func in dict.items(): 280 280 d = {'method': method, 'func': func} 281 if type(toPart) == types.StringType:281 if isinstance(toPart, basestring): 282 282 execString = \ 283 283 __stringBody % {'method' : method, 'attribute' : toPart} … … 582 582 if widgetClass is None: 583 583 return None 584 if len(widgetArgs) == 1 and type(widgetArgs[0]) == types.TupleType:584 if len(widgetArgs) == 1 and isinstance(widgetArgs[0], tuple): 585 585 # Arguments to the constructor can be specified as either 586 586 # multiple trailing arguments to createcomponent() or as a … … 1121 1121 # winfo_parent() should return the parent widget, but the 1122 1122 # the current version of Tkinter returns a string. 1123 if type(parent) == types.StringType:1123 if isinstance(parent, basestring): 1124 1124 parent = self._hull._nametowidget(parent) 1125 1125 master = parent.winfo_toplevel() … … 1133 1133 1134 1134 parent = self.winfo_parent() 1135 if type(parent) == types.StringType:1135 if isinstance(parent, basestring): 1136 1136 parent = self._hull._nametowidget(parent) 1137 1137 … … 1208 1208 # winfo_parent() should return the parent widget, but the 1209 1209 # the current version of Tkinter returns a string. 1210 if type(parent) == types.StringType:1210 if isinstance(parent, basestring): 1211 1211 parent = self._hull._nametowidget(parent) 1212 1212 master = parent.winfo_toplevel() … … 1574 1574 1575 1575 _callToTkReturned = 0 1576 if len(args) == 1 and type(args[0]) == types.TupleType:1576 if len(args) == 1 and isinstance(args[0], tuple): 1577 1577 argStr = str(args[0]) 1578 1578 else: … … 1843 1843 msg = msg + ' Args: %s\n' % str(args) 1844 1844 1845 if type(args) == types.TupleTypeand len(args) > 0 and \1845 if isinstance(args, tuple) and len(args) > 0 and \ 1846 1846 hasattr(args[0], 'type'): 1847 1847 eventArg = 1 … … 2138 2138 def _buttons(self): 2139 2139 buttons = self['buttons'] 2140 if type(buttons) != types.TupleType and type(buttons) != types.ListType:2140 if not isinstance(buttons, (tuple, list)): 2141 2141 raise ValueError('bad buttons option "%s": should be a tuple' 2142 2142 % str(buttons)) … … 2774 2774 def index(self, index, forInsert = 0): 2775 2775 listLength = len(self._buttonList) 2776 if type(index) == types.IntType:2776 if isinstance(index, int): 2777 2777 if forInsert and index <= listLength: 2778 2778 return index … … 3001 3001 3002 3002 sequences = root.bind_class(tag) 3003 if type(sequences) is types.StringType:3003 if isinstance(sequences, basestring): 3004 3004 # In old versions of Tkinter, bind_class returns a string 3005 3005 sequences = root.tk.splitlist(sequences) … … 3053 3053 } 3054 3054 opt = self['validate'] 3055 if type(opt) is types.DictionaryType:3055 if isinstance(opt, dict): 3056 3056 dict.update(opt) 3057 3057 else: … … 3089 3089 self._previousText = None 3090 3090 3091 if type(dict['min']) == types.StringTypeand strFunction is not None:3091 if isinstance(dict['min'], basestring) and strFunction is not None: 3092 3092 dict['min'] = apply(strFunction, (dict['min'],), args) 3093 if type(dict['max']) == types.StringTypeand strFunction is not None:3093 if isinstance(dict['max'], basestring) and strFunction is not None: 3094 3094 dict['max'] = apply(strFunction, (dict['max'],), args) 3095 3095 … … 3705 3705 return 3706 3706 3707 if type(traverseSpec) == types.IntType:3707 if isinstance(traverseSpec, int): 3708 3708 kw['underline'] = traverseSpec 3709 3709 return … … 3729 3729 name = kw['label'] 3730 3730 3731 if type(traverseSpec) == types.StringType:3731 if isinstance(traverseSpec, basestring): 3732 3732 lowerLetter = string.lower(traverseSpec) 3733 3733 if traverseSpec in name and lowerLetter not in hotkeyList: … … 3948 3948 return 3949 3949 3950 if type(traverseSpec) == types.IntType:3950 if isinstance(traverseSpec, int): 3951 3951 kw['underline'] = traverseSpec 3952 3952 return … … 3981 3981 name = kw[textKey] 3982 3982 3983 if type(traverseSpec) == types.StringType:3983 if isinstance(traverseSpec, basestring): 3984 3984 lowerLetter = string.lower(traverseSpec) 3985 3985 if traverseSpec in name and lowerLetter not in hotkeyList: … … 4503 4503 def index(self, index, forInsert = 0): 4504 4504 listLength = len(self._pageNames) 4505 if type(index) == types.IntType:4505 if isinstance(index, int): 4506 4506 if forInsert and index <= listLength: 4507 4507 return index … … 4968 4968 def index(self, index): 4969 4969 listLength = len(self._itemList) 4970 if type(index) == types.IntType:4970 if isinstance(index, int): 4971 4971 if index < listLength: 4972 4972 return index … … 5218 5218 # Parse <args> for options. 5219 5219 for arg, value in args.items(): 5220 if type(value) == types.FloatType:5220 if isinstance(value, float): 5221 5221 relvalue = value 5222 5222 value = self._absSize(relvalue) … … 5806 5806 5807 5807 listLength = len(self._buttonList) 5808 if type(index) == types.IntType:5808 if isinstance(index, int): 5809 5809 if index < listLength: 5810 5810 return index … … 6416 6416 def xview(self, mode = None, value = None, units = None): 6417 6417 6418 if type(value) == types.StringType:6418 if isinstance(value, basestring): 6419 6419 value = string.atof(value) 6420 6420 if mode is None: … … 6438 6438 def yview(self, mode = None, value = None, units = None): 6439 6439 6440 if type(value) == types.StringType:6440 if isinstance(value, basestring): 6441 6441 value = string.atof(value) 6442 6442 if mode is None: … … 6732 6732 # Add the items specified by the initialisation option. 6733 6733 items = self['items'] 6734 if type(items) != types.TupleType:6734 if not isinstance(items, tuple): 6735 6735 items = tuple(items) 6736 6736 if len(items) > 0: … … 6806 6806 self._listbox.selection_clear(0, 'end') 6807 6807 listitems = list(self._listbox.get(0, 'end')) 6808 if type(textOrList) == types.StringType:6808 if isinstance(textOrList, basestring): 6809 6809 if textOrList in listitems: 6810 6810 self._listbox.selection_set(listitems.index(textOrList)) … … 6821 6821 self._listbox.delete(0, 'end') 6822 6822 if len(items) > 0: 6823 if type(items) != types.TupleType:6823 if not isinstance(items, tuple): 6824 6824 items = tuple(items) 6825 6825 apply(self._listbox.insert, (0,) + items) … … 8349 8349 8350 8350 def selectitem(self, index, setentry=1): 8351 if type(index) == types.StringType:8351 if isinstance(index, basestring): 8352 8352 text = index 8353 8353 items = self._list.get(0, 'end') … … 8823 8823 datatype = self['datatype'] 8824 8824 8825 if type(datatype) is types.DictionaryType:8825 if isinstance(datatype, dict): 8826 8826 self._counterArgs = datatype.copy() 8827 8827 if self._counterArgs.has_key('counter'):
Note: See TracChangeset
for help on using the changeset viewer.