diff --git a/direct/src/gui/DirectCheckButton.py b/direct/src/gui/DirectCheckButton.py index af94647ab1..fa0f445d0b 100644 --- a/direct/src/gui/DirectCheckButton.py +++ b/direct/src/gui/DirectCheckButton.py @@ -19,7 +19,7 @@ class DirectCheckButton(DirectButton): # state can have a different text/geom/image # State transitions happen automatically based upon mouse interaction # Responds to click event and calls command if None - + self.colors = None optiondefs = ( ('indicatorValue', 0, self.setIndicatorValue), @@ -46,25 +46,25 @@ class DirectCheckButton(DirectButton): text = ('X', 'X'), relief = self['boxRelief'], ) - + # Call option initialization functions self.initialiseoptions(DirectCheckButton) - # After initialization with X giving it the correct size, put back space + # After initialization with X giving it the correct size, put back space if self['boxImage'] == None: self.indicator['text'] = (' ', '*') - self.indicator['text_pos'] = (0,-.2) + self.indicator['text_pos'] = (0, -.2) else: self.indicator['text'] = (' ', ' ') if self['boxImageColor'] != None and self['boxImage'] != None: - self.colors = [VBase4(0,0,0,0), self['boxImageColor']] - self.component('indicator')['image_color'] = VBase4(0,0,0,0) - + self.colors = [VBase4(0, 0, 0, 0), self['boxImageColor']] + self.component('indicator')['image_color'] = VBase4(0, 0, 0, 0) + # Override the resetFrameSize of DirectGuiWidget inorder to provide space for label def resetFrameSize(self): self.setFrameSize(fClearFrame = 1) - + def setFrameSize(self, fClearFrame = 0): - + if self['frameSize']: # Use user specified bounds self.bounds = self['frameSize'] @@ -125,7 +125,7 @@ class DirectCheckButton(DirectButton): (frameType != PGFrameStyle.TFlat)): bw = self['borderWidth'] else: - bw = (0,0) + bw = (0, 0) # Set frame to new dimensions self.guiItem.setFrame( self.bounds[0] - bw[0], @@ -137,7 +137,7 @@ class DirectCheckButton(DirectButton): if not self.indicator['pos']: bbounds = self.bounds lbounds = self.indicator.bounds - newpos = [0,0,0] + newpos = [0, 0, 0] if self['boxPlacement'] == 'left': #left newpos[0] += bbounds[0]-lbounds[0] + self['boxBorder'] + ibw[0] @@ -154,18 +154,18 @@ class DirectCheckButton(DirectButton): else: #below newpos[2] += bbounds[2]-lbounds[2] + self['boxBorder'] + ibw[1] - self.indicator.setPos(newpos[0],newpos[1],newpos[2]) + self.indicator.setPos(newpos[0], newpos[1], newpos[2]) + - def commandFunc(self, event): self['indicatorValue'] = 1 - self['indicatorValue'] if self.colors != None: self.component('indicator')['image_color'] = self.colors[self['indicatorValue']] - + if self['command']: # Pass any extra args to command apply(self['command'], [self['indicatorValue']] + self['extraArgs']) - + def setIndicatorValue(self): self.component('indicator').guiItem.setState(self['indicatorValue']) if self.colors != None: diff --git a/direct/src/gui/DirectDialog.py b/direct/src/gui/DirectDialog.py index 07c1a2ee0e..08eeb3de33 100644 --- a/direct/src/gui/DirectDialog.py +++ b/direct/src/gui/DirectDialog.py @@ -4,7 +4,7 @@ from DirectButton import * def findDialog(uniqueName): """findPanel(string uniqueName) - + Returns the panel whose uniqueName is given. This is mainly useful for debugging, to get a pointer to the current onscreen panel of a particular type. @@ -48,7 +48,7 @@ class DirectDialog(DirectFrame): buttonImageList List of images to show on each button buttonValueList List of values sent to dialog command for each button. If value is [] then the - ordinal rank of the button is used as + ordinal rank of the button is used as its value buttonHotKeyList List of hotkeys to bind to each button. Typing hotkey is equivalent to pressing @@ -64,7 +64,7 @@ class DirectDialog(DirectFrame): midPad Extra space added between text/buttons sidePad Extra space added to either side of text/buttons - buttonPadSF Scale factor used to expand/contract + buttonPadSF Scale factor used to expand/contract button horizontal spacing command Callback command used when a button is pressed. Value supplied to command @@ -75,7 +75,7 @@ class DirectDialog(DirectFrame): Values of None are substituted for lists that are shorter than the max length """ - + # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget @@ -95,8 +95,8 @@ class DirectDialog(DirectFrame): ('buttonImageList', [], INITOPT), ('buttonValueList', [], INITOPT), ('buttonHotKeyList', [], INITOPT), - ('button_borderWidth',(.01,.01), None), - ('button_pad', (.01,.01), None), + ('button_borderWidth', (.01, .01), None), + ('button_pad', (.01, .01), None), ('button_relief', RAISED, None), ('button_text_scale', 0.06, None), ('buttonSize', None, INITOPT), @@ -126,7 +126,7 @@ class DirectDialog(DirectFrame): # Store this panel in our map of all open panels. DirectDialog.AllDialogs[self['dialogName']] = self DirectDialog.PanelIndex += 1 - + # Determine number of buttons self.numButtons = max(len(self['buttonTextList']), len(self['buttonGeomList']), @@ -186,9 +186,9 @@ class DirectDialog(DirectFrame): extraArgs = [value]) self.bind('press-' + key + '-', self.buttonCommand, extraArgs = [value]) - + else: - button.bind('press-' + hotKey + '-',self.buttonCommand, + button.bind('press-' + hotKey + '-', self.buttonCommand, extraArgs = [value]) self.bind('press-' + hotKey + '-', self.buttonCommand, extraArgs = [value]) @@ -247,7 +247,7 @@ class DirectDialog(DirectFrame): bt += bpad[1] # Now resize buttons to match largest for button in self.buttonList: - button['frameSize'] = (bl,br,bb,bt) + button['frameSize'] = (bl, br, bb, bt) # Must compensate for scale scale = self['button_scale'] # Can either be a Vec3 or a tuple of 3 values @@ -283,7 +283,7 @@ class DirectDialog(DirectFrame): bl = br = bb = bt = 0 bPos = 0 bMax = 0 - bpad = (0,0) + bpad = (0, 0) bHeight = bWidth = 0 # Resize frame to fit text and buttons l = min(bPos + bl, l) - pad[0] @@ -296,7 +296,7 @@ class DirectDialog(DirectFrame): t = t + self['topPad'] + pad[1] self['image_scale'] = (r - l, 1, t - b) # Center frame about text and buttons - self['image_pos'] = ((l+r)*0.5, 0.0,(b+t)*0.5) + self['image_pos'] = ((l+r)*0.5, 0.0, (b+t)*0.5) self.resetFrameSize() def show(self): @@ -316,7 +316,7 @@ class DirectDialog(DirectFrame): def setMessage(self, message): self['text'] = message self.configureDialog() - + def cleanup(self): # Remove this panel out of the AllDialogs list uniqueName = self['dialogName'] @@ -348,7 +348,7 @@ class OkCancelDialog(DirectDialog): optiondefs = ( # Define type of DirectGuiWidget ('buttonTextList', ['OK','Cancel'], INITOPT), - ('buttonValueList', [DIALOG_OK,DIALOG_CANCEL], INITOPT), + ('buttonValueList', [DIALOG_OK, DIALOG_CANCEL], INITOPT), ) # Merge keyword options with default options self.defineoptions(kw, optiondefs) @@ -361,7 +361,7 @@ class YesNoDialog(DirectDialog): optiondefs = ( # Define type of DirectGuiWidget ('buttonTextList', ['Yes', 'No'], INITOPT), - ('buttonValueList', [DIALOG_YES,DIALOG_NO], INITOPT), + ('buttonValueList', [DIALOG_YES, DIALOG_NO], INITOPT), ) # Merge keyword options with default options self.defineoptions(kw, optiondefs) @@ -374,7 +374,7 @@ class YesNoCancelDialog(DirectDialog): optiondefs = ( # Define type of DirectGuiWidget ('buttonTextList', ['Yes', 'No', 'Cancel'], INITOPT), - ('buttonValueList', [DIALOG_YES,DIALOG_NO,DIALOG_CANCEL], + ('buttonValueList', [DIALOG_YES, DIALOG_NO, DIALOG_CANCEL], INITOPT), ) # Merge keyword options with default options @@ -388,7 +388,7 @@ class RetryCancelDialog(DirectDialog): optiondefs = ( # Define type of DirectGuiWidget ('buttonTextList', ['Retry','Cancel'], INITOPT), - ('buttonValueList', [DIALOG_RETRY,DIALOG_CANCEL], INITOPT), + ('buttonValueList', [DIALOG_RETRY, DIALOG_CANCEL], INITOPT), ) # Merge keyword options with default options self.defineoptions(kw, optiondefs) diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index f7e9af25d8..9a6f3634e2 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -13,7 +13,7 @@ class DirectEntry(DirectFrame): """ directWtext = ConfigVariableBool('direct-wtext', 1) - + def __init__(self, parent = None, **kw): # Inherits from DirectFrame # A Direct Frame can have: @@ -48,9 +48,9 @@ class DirectEntry(DirectFrame): ('extraArgs', [], None), # commands to be called when focus is gained or lost ('focusInCommand', None, None), - ('focusInExtraArgs',[], None), - ('focusOutCommand',None, None), - ('focusOutExtraArgs',[], None), + ('focusInExtraArgs', [], None), + ('focusOutCommand', None, None), + ('focusOutExtraArgs', [], None), # Sounds to be used for button events ('rolloverSound', getDefaultRolloverSound(), self.setRolloverSound), ('clickSound', getDefaultClickSound(), self.setClickSound), @@ -64,7 +64,7 @@ class DirectEntry(DirectFrame): if self['entryFont'] == None: font = getDefaultFont() else: - font = self['entryFont'] + font = self['entryFont'] # Create Text Node Component self.onscreenText = self.createcomponent( @@ -146,11 +146,11 @@ class DirectEntry(DirectFrame): def focusInCommandFunc(self): if self['focusInCommand']: apply(self['focusInCommand'], self['focusInExtraArgs']) - + def focusOutCommandFunc(self): if self['focusOutCommand']: apply(self['focusOutCommand'], self['focusOutExtraArgs']) - + def set(self, text): self.unicodeText = isinstance(text, types.UnicodeType) if self.unicodeText: @@ -164,7 +164,7 @@ class DirectEntry(DirectFrame): # return an 8-bit string. This will be encoded if # necessary, according to Panda's default encoding. return self.guiItem.getText() - + if self.unicodeText: return self.guiItem.getWtext() else: @@ -187,7 +187,7 @@ class DirectEntry(DirectFrame): self.guiItem.setCursorPosition(len(self.get()) + pos) else: self.guiItem.setCursorPosition(pos) - + def enterText(self, text): """ sets the entry's text, and moves the cursor to the end """ self.set(text) @@ -215,7 +215,7 @@ class DirectEntry(DirectFrame): bottom = -0.3 * lineHeight - (lineHeight * (numLines - 1)) top = lineHeight - + self.ll.set(left, 0.0, bottom) self.ur.set(right, 0.0, top) self.ll = mat.xformPoint(self.ll) diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index ac018edf0b..249c3e08c0 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -35,7 +35,7 @@ Code Overview: a dictionary of the keyword options specified as part of the constructor keywords can be of the form 'component_option', where component is the name of a widget's component, a component group or a component alias - + self._dynamicGroups, a list of group names for which it is permissible to specify options before components of that group are created. If a widget is a derived class the order of execution would be: @@ -156,7 +156,7 @@ class DirectGuiBase(DirectObject.DirectObject): # to call when the value is changed. If any option created by # base classes has the same name as one in , the # base class's value and function will be overriden. - + # keywords is a dictionary of keyword/value pairs from the constructor # optionDefs is a dictionary of default options for the widget # dynamicGroups is a tuple of component groups for which you can @@ -178,20 +178,20 @@ class DirectGuiBase(DirectObject.DirectObject): self._dynamicGroups = self._dynamicGroups + tuple(dynamicGroups) # Reconcile command line and default options self.addoptions(optionDefs) - + def addoptions(self, optionDefs): """ addoptions(optionDefs) - add option def to option info """ # Add additional options, providing the default value and the # method to call when the value is changed. See # "defineoptions" for more details - + # optimisations: optionInfo = self._optionInfo optionInfo_has_key = optionInfo.has_key keywords = self._constructorKeywords keywords_has_key = keywords.has_key FUNCTION = _OPT_FUNCTION - + for name, default, function in optionDefs: if '_' not in name: # The option will already exist if it has been defined @@ -218,10 +218,10 @@ class DirectGuiBase(DirectObject.DirectObject): # of an option of a component of a base class. if not keywords_has_key(name): keywords[name] = [default, 0] - + def initialiseoptions(self, myClass): """ - Call all initialisation functions to initialize widget + Call all initialisation functions to initialize widget options to default of keyword value """ # This is to make sure this method class is only called by @@ -262,13 +262,13 @@ class DirectGuiBase(DirectObject.DirectObject): def postInitialiseFunc(self): for func in self.postInitialiseFuncList: func() - + def isinitoption(self, option): """ Is this opition one that can only be specified at construction? """ return self._optionInfo[option][_OPT_FUNCTION] is INITOPT - + def options(self): """ Print out a list of available widget options. @@ -282,7 +282,7 @@ class DirectGuiBase(DirectObject.DirectObject): options.append((option, default, isinit)) options.sort() return options - + def configure(self, option=None, **kw): """ configure(option = None) @@ -301,7 +301,7 @@ class DirectGuiBase(DirectObject.DirectObject): # # If *option* is a string, return the 3 element tuple for the # given configuration option. - + # First, deal with the option queries. if len(kw) == 0: # This configure call is querying the values of one or all options. @@ -317,7 +317,7 @@ class DirectGuiBase(DirectObject.DirectObject): else: config = self._optionInfo[option] return (option, config[_OPT_DEFAULT], config[_OPT_VALUE]) - + # optimizations: optionInfo = self._optionInfo optionInfo_has_key = optionInfo.has_key @@ -327,11 +327,11 @@ class DirectGuiBase(DirectObject.DirectObject): componentAliases_has_key = componentAliases.has_key VALUE = _OPT_VALUE FUNCTION = _OPT_FUNCTION - + # This will contain a list of options in *kw* which # are known to this gui item. directOptions = [] - + # This will contain information about the options in # *kw* of the form _