Example #1
0
    def setup(self, attribute, window, aguidata):
        for child in self.control.GetChildren():
            if isinstance(child, wx.TopLevelWindow):
                wx.CallAfter( child.Close)
#        aguidata.setdefault('background_color', self.defaultBackgroundColor)
        aguidata.setdefault('doc', "")
        aguidata.setdefault('label','   components')
        try:
            resetObject = self.object != window.object
        except:
            resetObject = True
        if resetObject:
            self.object = window.object
#            self.addTree.object = self.object
            self.editList.object = self.object
        try:
            selectComponent = self.editList.get_selected()
        except:
            selectComponent = None
#        try:
#            selectAddComponent = self.addTree.tree.GetStringValue()
#        except:
#            selectAddComponent = ""
        self.editList.refresh_components( selectComponent)
#        self.addTree.create_tree( self.object)
#        self.addTree.tree.SetStringValue( selectAddComponent)
        Base.setup(self, attribute, window, aguidata)
Example #2
0
 def setup(self, attribute, window, aguidata):
     #self.floatspin.SetRange( *self.aguidata.get('range',(None,None)))
     self.minval, self.maxval = self.aguidata.get('range', (None, None))
     self.floatspin.SetIncrement(self.aguidata.get('increment', 0.1))
     self.floatspin.SetFormat(self.aguidata.get('format', "%f"))
     self.floatspin.SetDigits(self.aguidata.get('digits', 2))
     Base.setup(self, attribute, window, aguidata)
Example #3
0
 def setup(self, attribute, window, aguidata):
     for child in self.control.GetChildren():
         if isinstance(child, wx.TopLevelWindow):
             wx.CallAfter(child.Close)
     #        aguidata.setdefault('background_color', self.defaultBackgroundColor)
     aguidata.setdefault("doc", "")
     aguidata.setdefault("label", "   components")
     try:
         resetObject = self.object != window.object
     except:
         resetObject = True
     if resetObject:
         self.object = window.object
         #            self.addTree.object = self.object
         self.editList.object = self.object
     try:
         selectComponent = self.editList.get_selected()
     except:
         selectComponent = None
     #        try:
     #            selectAddComponent = self.addTree.tree.GetStringValue()
     #        except:
     #            selectAddComponent = ""
     self.editList.refresh_components(selectComponent)
     #        self.addTree.create_tree( self.object)
     #        self.addTree.tree.SetStringValue( selectAddComponent)
     Base.setup(self, attribute, window, aguidata)
Example #4
0
 def setup(self, attribute, window, aguidata):
     #self.floatspin.SetRange( *self.aguidata.get('range',(None,None)))
     self.minval, self.maxval = self.aguidata.get('range',(None,None))
     self.floatspin.SetIncrement(self.aguidata.get('increment',0.1))
     self.floatspin.SetFormat(self.aguidata.get('format',"%f"))
     self.floatspin.SetDigits(self.aguidata.get('digits',2))
     Base.setup(self, attribute, window, aguidata)
Example #5
0
 def setup(self, attribute, window, aguidata):
     if self.aguidata != aguidata:
         self.control.Destroy()
         self.label.Destroy()
         self.__init__(attribute, window, aguidata)
         return
     else:
         Base.setup( self, attribute, window, aguidata)        
Example #6
0
 def setup(self, attribute, window, aguidata):
     if self.aguidata != aguidata:
         self.control.Destroy()
         self.label.Destroy()
         self.__init__(attribute, window, aguidata)
         return
     else:
         Base.setup(self, attribute, window, aguidata)
Example #7
0
 def setup(self, attribute, window, aguidata):
     if aguidata != self.aguidata:
         self.control.Destroy()
         self.label.Destroy()            
         self.__init__( attribute, window, aguidata)
         return
     else:
         self.setup_buttons( window.object)
         self.set_control_value( window.object)
         Base.setup( self, attribute, window, aguidata)
Example #8
0
 def setup(self, attribute, window, aguidata):
     if aguidata != self.aguidata:
         self.control.Destroy()
         self.label.Destroy()
         self.__init__(attribute, window, aguidata)
         return
     else:
         self.setup_buttons(window.object)
         self.set_control_value(window.object)
         Base.setup(self, attribute, window, aguidata)
Example #9
0
 def setup(self, attribute, window, aguidata):
     aguidata['control_only'] = True
     fontsize = aguidata.get('font_size', self.defaultFontSize)
     if fontsize != self.aguidata.get('font_size', self.defaultFontSize):
         self.control.Destroy()
         self.label.Destroy()
         self.__init__(attribute, window, aguidata)
         return
     if attribute:
         aguidata.setdefault('label', attribute)
     labelText = aguidata.get('label', '')
     self.control.textCtrl.SetLabel(labelText)
     aguidata.setdefault('background_color', self.defaultBackgroundColor)
     Base.setup(self, '', window, aguidata)
Example #10
0
 def setup(self, attribute, window, aguidata):
     if self.allow_typing != aguidata.get('allow_typing', False):
         self.control.Destroy()
         self.label.Destroy()
         self.__init__( attribute, window, aguidata)
         return
     if _DEBUG: print "DropDown.setup attribute:",attribute
     self.callback = aguidata.get('callback',  None)
     self.sort = aguidata.get('sort', True)
     self.list_generator = aguidata.get('list_generator', None)
     if self.list_generator:
         self.listctrl.SetPopupCallback(self.setup_listctrl)
     else:
         self.listctrl.SetPopupCallback(None)
     Base.setup(self, attribute, window, aguidata)
     self.setup_listctrl(self.aguidata.get('list',[]))
     self.set_control_value(self.get_attribute_value())
Example #11
0
 def setup(self, attribute, window, aguidata):
     Base.setup(self, attribute, window, aguidata)
Example #12
0
File: text.py Project: bcorfman/pug
 def setup(self, attribute, window, aguidata):
     Base.setup(self, attribute, window, aguidata)
Example #13
0
    def setup(self, attribute, window, aguidata):
        use_defaults = aguidata.get('use_defaults', False)

        # check if the callable is provided or if it's a true attribute
        if aguidata.get('routine', False):
            value = aguidata['routine']
            self.routine = value
            if not aguidata.get('label', None):
                if attribute:
                    aguidata['label'] = attribute
                else:
                    aguidata['label'] = self.routine.__name__
            attribute = ''
        else:
            value = getattr(window.object, attribute, None)
        isMethod = bool(ismethod(value) and value.im_self)
        doc = None
        if aguidata.has_key('doc'):
            doc = aguidata['doc']
        else:
            doc = getdoc(value)
            if doc:
                aguidata['doc'] = doc

        # analyze the routine's arguments
        if callable(value):
            self.takesargs = False
            self.needsargs = False
            self.notpython = False
            try:
                argspec = getargspec(value)
            except:
                self.notpython = True
                arguments = "?args unknown?"
            else:
                arglist = []
                if isMethod and len(argspec[0]):
                    argspec[0].pop(0)
                if argspec[0]:
                    self.takesargs = True
                    mainargs = []
                    for arg in argspec[0]:
                        if type(arg) in StringTypes:
                            mainargs.append(arg)
                        else:
                            try:
                                l = ''.join(["(", arg[0]])
                                for item in arg[1:]:
                                    l = ''.join([l, ", ", item])
                                l = ''.join([l, ")"])
                                mainargs.append(l)
                            except:
                                mainargs.append(repr(arg))
                    if argspec[3]:
                        argcount = len(argspec[0])
                        if argcount < len(argspec[3]):
                            self.needsargs = True
                        for idx in range(argcount):
                            kwidx = idx - (argcount - len(argspec[3]))
                            if kwidx >= 0:
                                mainargs[idx] = ''.join([
                                    mainargs[idx], '=',
                                    repr(argspec[3][kwidx])
                                ])
                    arglist += mainargs
                if argspec[1]:
                    arglist += [''.join(['*', argspec[1]])]
                    self.takesargs = True
                if argspec[2]:
                    arglist += [''.join(['**', argspec[2]])]
                    self.takesargs = True
                arguments = ', '.join(arglist)
                arguments = ''.join(["(", arguments, ")"])
        else:
            arguments = "?Not Callable?"
        self.arguments = arguments

        if (self.takesargs or self.notpython) and \
                not(use_defaults and not self.needsargs):
            bmp = wx.ART_HELP_SIDE_PANEL
            if doc:
                tooltip = doc
            else:
                tooltip = "Enter arguments"
            fn = self.openExecuteWindow
        else:
            bmp = wx.ART_GO_FORWARD
            if doc:
                tooltip = doc
            else:
                tooltip = "Execute"
            fn = self.execute
            if self.aguidata.get('show_parens', False):
                arguments = '( )'
            else:
                arguments = ''
        buttonSize = WX_BUTTON_BMP_SIZE
        run_bmp = wx.ArtProvider.GetBitmap(bmp, wx.ART_TOOLBAR, buttonSize)
        self.runButton.SetBitmapLabel(run_bmp)
        self.runButton.SetToolTipString(tooltip)
        self.control.Unbind(wx.EVT_BUTTON, self.runButton)
        self.control.Bind(wx.EVT_BUTTON, fn, self.runButton)
        self.infoText.SetLabel(arguments)
        Base.setup(self, attribute, window, aguidata)
Example #14
0
    def setup(self, attribute, window, aguidata):
        use_defaults = aguidata.get('use_defaults', False)

        # check if the callable is provided or if it's a true attribute
        if aguidata.get('routine', False):
            value = aguidata['routine']
            self.routine = value
            if not aguidata.get('label', None):
                if attribute:
                    aguidata['label'] = attribute
                else:
                    aguidata['label'] = self.routine.__name__
            attribute = ''
        else:
            value = getattr(window.object,attribute, None)
        isMethod = bool(ismethod(value) and value.im_self)
        doc = None
        if aguidata.has_key('doc'):
            doc = aguidata['doc']
        else:
            doc = getdoc(value)
            if doc:
                aguidata['doc'] = doc

        # analyze the routine's arguments 
        if callable(value):
            self.takesargs = False
            self.needsargs = False
            self.notpython = False
            try:
                argspec = getargspec(value)
            except:
                self.notpython = True
                arguments = "?args unknown?"
            else:
                arglist = []
                if isMethod and len(argspec[0]):
                    argspec[0].pop(0)
                if argspec[0]:
                    self.takesargs = True
                    mainargs = []
                    for arg in argspec[0]:
                        if type(arg) in StringTypes:
                            mainargs.append(arg)
                        else:
                            try:
                                l = ''.join(["(",arg[0]])
                                for item in arg[1:]:
                                    l = ''.join([l,", ",item])
                                l = ''.join([l,")"])
                                mainargs.append(l)
                            except:
                                mainargs.append(repr(arg))
                    if argspec[3]:
                        argcount = len(argspec[0])
                        if argcount < len(argspec[3]):
                            self.needsargs = True
                        for idx in range(argcount):
                            kwidx = idx - (argcount - len(argspec[3])) 
                            if kwidx >= 0:
                                mainargs[idx] = ''.join([mainargs[idx],
                                                '=',repr(argspec[3][kwidx])])
                    arglist += mainargs
                if argspec[1]:
                    arglist += [''.join([ '*',argspec[1]])]
                    self.takesargs = True
                if argspec[2]:
                    arglist += [''.join([ '**',argspec[2]])]
                    self.takesargs = True
                arguments = ', '.join(arglist)
                arguments = ''.join(["(",arguments,")"])
        else:
            arguments = "?Not Callable?"
        self.arguments = arguments
        
        if (self.takesargs or self.notpython) and \
                not(use_defaults and not self.needsargs):
            bmp = wx.ART_HELP_SIDE_PANEL
            if doc:
                tooltip = doc
            else:
                tooltip = "Enter arguments"       
            fn = self.openExecuteWindow
        else:
            bmp = wx.ART_GO_FORWARD
            if doc:
                tooltip = doc
            else:
                tooltip = "Execute"
            fn = self.execute
            if self.aguidata.get('show_parens',False):
                arguments = '( )'
            else:
                arguments = ''
        buttonSize=WX_BUTTON_BMP_SIZE
        run_bmp = wx.ArtProvider.GetBitmap(bmp, 
                                        wx.ART_TOOLBAR, buttonSize)        
        self.runButton.SetBitmapLabel(run_bmp)
        self.runButton.SetToolTipString(tooltip)
        self.control.Unbind(wx.EVT_BUTTON, self.runButton)
        self.control.Bind(wx.EVT_BUTTON, fn, self.runButton)  
        self.infoText.SetLabel( arguments)   
        Base.setup(self, attribute, window, aguidata) 
Example #15
0
 def setup(self, attribute, window, aguidata):
     aguidata.setdefault('do_typecast', True)
     Base.setup(self, attribute, window, aguidata)
Example #16
0
 def setup(self, attribute, window, aguidata):
     aguidata.setdefault('do_typecast',True)
     Base.setup(self, attribute, window, aguidata)