Beispiel #1
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        label = wx.Panel(window, style=0)
        #background color
        if not hasattr(self, 'defaultBackgroundColor'):
            backgroundColor = label.GetBackgroundColour()
            r = backgroundColor[0]
            g = backgroundColor[1]
            b = backgroundColor[2]
            r -= 30
            g -= 30
            b -= 30
            if r < 0: r = 0
            if g < 0: g = 0
            if b < 0: b = 0
            backgroundColor.Set(r, g, b)
            self.__class__.defaultBackgroundColor = backgroundColor

        #label
        if not hasattr(self, 'defaultFontSize'):
            dummyText = wx.StaticText(label)
            defaultFont = dummyText.GetFont()
            dummyText.Destroy()
            self.__class__.defaultFontSize = defaultFont.GetPointSize()
        aguidata.setdefault('font_size', self.defaultFontSize)
        font = wx.Font(aguidata['font_size'], wx.SWISS, wx.NORMAL,
                       wx.FONTWEIGHT_BOLD)
        textSizer = AguiLabelSizer(parent=label, line=False, font=font)
        label.SetSizer(textSizer)
        label.textCtrl = textSizer.textCtrl
        # label.preferredWidth = textSizer.preferredWidth # FOR SASH

        aguidata.setdefault('label', attribute)
        kwargs['aguidata'] = aguidata
        kwargs['control_widget'] = label
        Base.__init__(self, '', window, **kwargs)
Beispiel #2
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
                    
        #control
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient = wx.VERTICAL)
        self.sizer = sizer
        #edit
        editSizer = wx.BoxSizer(orient = wx.HORIZONTAL)
        sizer.Add(editSizer,flag=wx.EXPAND)
        # list of components on object
        editList = ComponentList(parent=control, size=WX_BUTTON_SIZE)
        editList.SetToolTipString("Components attached to object")
        editList.SetPopupMinWidth(100)
        editSizer.Add(editList, 1, wx.EXPAND, 5)
        self.editList = editList
        # edit button
        edit_image = wx.Bitmap(get_image_path("edit.png"), wx.BITMAP_TYPE_PNG)
        editButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE,
                                                   bitmap=edit_image)
#        editButton.SetInitialSize((50,self.editList.Size[1]))
        editButton.SetToolTipString("Edit this component in a new window")
        editButton.Bind(wx.EVT_BUTTON, self.edit_button_click)
        self.editButton = editButton
        editSizer.Add(editButton, 0, wx.EAST)
        #delete
        remove_image = wx.Bitmap(get_image_path("delete.png"), 
                                 wx.BITMAP_TYPE_PNG)
        removeButton = wx.BitmapButton(control, 
                                    size=WX_BUTTON_SIZE, bitmap=remove_image)
        removeButton.SetToolTipString("Remove this component from object")
        removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click)
        editSizer.Add( removeButton,0, wx.EXPAND, 5)
        
        # add button
        add_image = wx.Bitmap(get_image_path("add.png"), wx.BITMAP_TYPE_PNG)
        
        addButton = wx.BitmapButton(control, 
                                    size=WX_BUTTON_SIZE, bitmap=add_image)
#        addButton.SetInitialSize(editButton.Size) 
        addButton.SetToolTipString("Pick a component to add to this object")
        addButton.Bind(wx.EVT_BUTTON, self.add_button_click)
        editSizer.Add( addButton, 0, wx.EAST)
                
        control.SetSizer(sizer)
        control.SetMinSize((-1, -1))  
        sizer.SetMinSize((-1,-1))        
        sizer.Fit(control)
#        addTree.SetMinSize((1,self.addTree.Size[1]))
        editList.SetMinSize((1,self.editList.Size[1]))
        
        kwargs['aguidata'] = aguidata
#        kwargs['label_widget'] = label
        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, **kwargs)
        
        # keep the pug function around for button pressing
        # don't know if this is the right way to do it
        from pug.syswx.pugframe import PugFrame
        self.pugframe = PugFrame
Beispiel #3
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):

        # control
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.sizer = sizer
        # edit
        editSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        sizer.Add(editSizer, flag=wx.EXPAND)
        # list of components on object
        editList = ComponentList(parent=control, size=WX_BUTTON_SIZE)
        editList.SetToolTipString("Components attached to object")
        editList.SetPopupMinWidth(100)
        editSizer.Add(editList, 1, wx.EXPAND, 5)
        self.editList = editList
        # edit button
        edit_image = wx.Bitmap(get_image_path("edit.png"), wx.BITMAP_TYPE_PNG)
        editButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=edit_image)
        #        editButton.SetInitialSize((50,self.editList.Size[1]))
        editButton.SetToolTipString("Edit this component in a new window")
        editButton.Bind(wx.EVT_BUTTON, self.edit_button_click)
        self.editButton = editButton
        editSizer.Add(editButton, 0, wx.EAST)
        # delete
        remove_image = wx.Bitmap(get_image_path("delete.png"), wx.BITMAP_TYPE_PNG)
        removeButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=remove_image)
        removeButton.SetToolTipString("Remove this component from object")
        removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click)
        editSizer.Add(removeButton, 0, wx.EXPAND, 5)

        # add button
        add_image = wx.Bitmap(get_image_path("add.png"), wx.BITMAP_TYPE_PNG)

        addButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=add_image)
        #        addButton.SetInitialSize(editButton.Size)
        addButton.SetToolTipString("Pick a component to add to this object")
        addButton.Bind(wx.EVT_BUTTON, self.add_button_click)
        editSizer.Add(addButton, 0, wx.EAST)

        control.SetSizer(sizer)
        control.SetMinSize((-1, -1))
        sizer.SetMinSize((-1, -1))
        sizer.Fit(control)
        #        addTree.SetMinSize((1,self.addTree.Size[1]))
        editList.SetMinSize((1, self.editList.Size[1]))

        kwargs["aguidata"] = aguidata
        #        kwargs['label_widget'] = label
        kwargs["control_widget"] = control
        Base.__init__(self, attribute, window, **kwargs)

        # keep the pug function around for button pressing
        # don't know if this is the right way to do it
        from pug.syswx.pugframe import PugFrame

        self.pugframe = PugFrame
Beispiel #4
0
 def __init__(self, attribute, window, aguidata={}, **kwargs):
     control = wx.Panel(window)
     sizer = wx.BoxSizer(orient=wx.VERTICAL)
     control.SetSizer(sizer)
     floatspin = FS.FloatSpin(control, agwStyle = FS.FS_LEFT)
     sizer.Add(floatspin,1,flag=wx.EXPAND)
     floatspin.Bind(wx.EVT_TEXT_ENTER, self.enter)
     floatspin.GetTextCtrl().Bind(wx.EVT_SET_FOCUS, self.enter)
     floatspin.GetTextCtrl().Bind(wx.EVT_KILL_FOCUS, self.exit)
     floatspin.Bind(FS.EVT_FLOATSPIN, self.apply)
     self.floatspin = floatspin
     kwargs['control_widget'] = control
     Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #5
0
 def __init__(self, attribute, window, aguidata={}, **kwargs):
     control = wx.Panel(window)
     sizer = wx.BoxSizer(orient=wx.VERTICAL)
     control.SetSizer(sizer)
     floatspin = FS.FloatSpin(control, agwStyle=FS.FS_LEFT)
     sizer.Add(floatspin, 1, flag=wx.EXPAND)
     floatspin.Bind(wx.EVT_TEXT_ENTER, self.enter)
     floatspin.GetTextCtrl().Bind(wx.EVT_SET_FOCUS, self.enter)
     floatspin.GetTextCtrl().Bind(wx.EVT_KILL_FOCUS, self.exit)
     floatspin.Bind(FS.EVT_FLOATSPIN, self.apply)
     self.floatspin = floatspin
     kwargs['control_widget'] = control
     Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #6
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT))
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        picker = wx.FontPickerCtrl(control)
#        checkbox.Bind(wx.EVT_CHECKBOX, self.apply)
#        checkbox.Bind(wx.EVT_SET_FOCUS, self.focus)
#        checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus)
        self.picker = picker
#        line = wx.StaticLine(control)
        sizer.Add(picker,1)
#       sizer.Add(line,flag=wx.EXPAND)
        control.SetSizer(sizer)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #7
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        control.SetSizer(sizer)
        textEntry = wx.TextCtrl( control)
#        textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT))
        sizer.Add(textEntry,1,flag=wx.EXPAND)
        textEntry.Bind(wx.EVT_TEXT_ENTER, self.apply)
        textEntry.Bind(wx.EVT_KILL_FOCUS, self.apply)
        self.textEntry = textEntry
#        textEntry = AguiTextCtrl( window)
#        control = textEntry

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #8
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT))
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        checkbox = wx.CheckBox(control, -1, label=" ")
        checkbox.Bind(wx.EVT_CHECKBOX, self.apply)
        #        checkbox.Bind(wx.EVT_SET_FOCUS, self.focus)
        #        checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus)
        self.checkbox = checkbox
        line = wx.StaticLine(control)
        sizer.Add(checkbox, 1, flag=wx.LEFT, border=5)
        sizer.Add(line, flag=wx.EXPAND)
        control.SetSizer(sizer)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #9
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT))
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        picker = wx.FontPickerCtrl(control)
        #        checkbox.Bind(wx.EVT_CHECKBOX, self.apply)
        #        checkbox.Bind(wx.EVT_SET_FOCUS, self.focus)
        #        checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus)
        self.picker = picker
        #        line = wx.StaticLine(control)
        sizer.Add(picker, 1)
        #       sizer.Add(line,flag=wx.EXPAND)
        control.SetSizer(sizer)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #10
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT))
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        checkbox = wx.CheckBox(control, -1, label=" ")
        checkbox.Bind(wx.EVT_CHECKBOX, self.apply)
#        checkbox.Bind(wx.EVT_SET_FOCUS, self.focus)
#        checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus)
        self.checkbox = checkbox
        line = wx.StaticLine(control)
        sizer.Add(checkbox,1,flag=wx.LEFT, border=5)
        sizer.Add(line,flag=wx.EXPAND)
        control.SetSizer(sizer)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #11
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        """__init__(self, attribute, window, aguidata, **kwargs)
        
special aguidata entries:
    'routine': the callable object that will be used. This is as an
        alternative to the attribute argument.
    'use_defaults': execute routine using all default args if possible
    'no_return_popup': if this is true, don't show a return value popup
    'show_parens': if True, show parenthesis even if method has no arguments
See Base attribute gui for other argument info
"""
        control = wx.Panel(window, 
                           size = (1,WX_STANDARD_HEIGHT))
        control.SetMinSize((-1,WX_STANDARD_HEIGHT))
        #widgets
        runButton = wx.BitmapButton(control, -1,  
                                            size=WX_BUTTON_SIZE)
        
        infoText = wx.StaticText(control)
        infoText.SetMinSize((-1,infoText.Size[1]))
        line = wx.StaticLine(control, style = 0) 
        self.runButton = runButton
        self.infoText = infoText

        # sizers
        textSizer = wx.BoxSizer(orient=wx.VERTICAL)
        textSizer.AddSpacer((1,WX_TEXTEDIT_LABEL_YOFFSET))
        textSizer.Add(infoText, 1)
        textSizer.Add(line, flag = wx.EXPAND | wx.BOTTOM)
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        control.SetSizer(controlSizer)
        controlSizer.Add(runButton)
        controlSizer.AddSpacer((3,3))
        controlSizer.Add(textSizer,1,wx.EXPAND)
        control.sizer = controlSizer
        control.textSizer = textSizer
        
        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
        
        from pug.syswx.pugframe import pug_frame
        self.pug_frame = pug_frame
Beispiel #12
0
 def __init__(self, attribute, window, aguidata={}, **kwargs):
     style = wx.TE_PROCESS_ENTER
     if aguidata.get('allow_typing', False):
         self.allow_typing = True
     else:
         self.allow_typing = False
         style |= wx.CB_READONLY
     control = wx.combo.ComboCtrl(parent=window,
                                  style=style)
     if _DEBUG: print "DropDown.__init__ attribute:",attribute
     control.SetMinSize((1,WX_STANDARD_HEIGHT))
     listctrl = ListCtrlComboPopup()
     self.listctrl = listctrl
     control.SetPopupControl(self.listctrl)
     self.listctrl.SetSelectCallback(self.item_selected)
     control.Bind(wx.EVT_TEXT_ENTER, self.item_selected)
     control.Bind(wx.EVT_KILL_FOCUS, self.lost_focus)
     control.Bind(wx.EVT_KEY_DOWN, self.OnKey)
     kwargs['control_widget'] = control
     Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #13
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        aguidata.setdefault('view_button',False)#,True)
        aguidata.setdefault('new_view_button',True)        
        #widgets
        control = wx.Panel(window, size=(1,WX_STANDARD_HEIGHT))
        control.SetMinSize((-1,WX_STANDARD_HEIGHT))
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)

        obj = getattr(window.object,attribute)
        control.value = obj
        
        if aguidata['new_view_button']:
            new_view_button = PugButton(control, obj,
                                   True, attribute, window)
            controlSizer.Add(new_view_button)
            self.new_view_button = new_view_button    
            self.new_view_button.Bind(wx.EVT_BUTTON, self.evt_view)
        elif self.new_view_button:
            self.new_view_button.Destroy()     

        if aguidata['view_button']:
            view_button = PugButton(control, obj,
                                   False, attribute, window)
            self.view_button = view_button
            controlSizer.Add(view_button)
            self.view_button.Bind(wx.EVT_BUTTON, self.evt_view) 
        elif self.view_button:
            self.view_button.Destroy()     
        
        textSizer = AguiLabelSizer(control)
        infoText = textSizer.textCtrl
        self.infoText = infoText
        self.textSizer = textSizer

        # sizers
        control.SetSizer(controlSizer)
        controlSizer.AddSpacer((3,3))        
        controlSizer.AddSizer(textSizer,1,wx.EXPAND)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #14
0
    def __init__(self, attribute, window, aguidata, **kwargs):
        """__init__(self, attribute, window, aguidata, **kwargs)
        
special aguidata entries:
    'routine': the callable object that will be used. This is as an
        alternative to the attribute argument.
    'use_defaults': execute routine using all default args if possible
    'no_return_popup': if this is true, don't show a return value popup
    'show_parens': if True, show parenthesis even if method has no arguments
See Base attribute gui for other argument info
"""
        control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT))
        control.SetMinSize((-1, WX_STANDARD_HEIGHT))
        #widgets
        runButton = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE)

        infoText = wx.StaticText(control)
        infoText.SetMinSize((-1, infoText.Size[1]))
        line = wx.StaticLine(control, style=0)
        self.runButton = runButton
        self.infoText = infoText

        # sizers
        textSizer = wx.BoxSizer(orient=wx.VERTICAL)
        textSizer.AddSpacer((1, WX_TEXTEDIT_LABEL_YOFFSET))
        textSizer.Add(infoText, 1)
        textSizer.Add(line, flag=wx.EXPAND | wx.BOTTOM)
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        control.SetSizer(controlSizer)
        controlSizer.Add(runButton)
        controlSizer.AddSpacer((3, 3))
        controlSizer.Add(textSizer, 1, wx.EXPAND)
        control.sizer = controlSizer
        control.textSizer = textSizer

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)

        from pug.syswx.pugframe import pug_frame
        self.pug_frame = pug_frame
Beispiel #15
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        aguidata.setdefault('view_button', False)  #,True)
        aguidata.setdefault('new_view_button', True)
        #widgets
        control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT))
        control.SetMinSize((-1, WX_STANDARD_HEIGHT))
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)

        obj = getattr(window.object, attribute)
        control.value = obj

        if aguidata['new_view_button']:
            new_view_button = PugButton(control, obj, True, attribute, window)
            controlSizer.Add(new_view_button)
            self.new_view_button = new_view_button
            self.new_view_button.Bind(wx.EVT_BUTTON, self.evt_view)
        elif self.new_view_button:
            self.new_view_button.Destroy()

        if aguidata['view_button']:
            view_button = PugButton(control, obj, False, attribute, window)
            self.view_button = view_button
            controlSizer.Add(view_button)
            self.view_button.Bind(wx.EVT_BUTTON, self.evt_view)
        elif self.view_button:
            self.view_button.Destroy()

        textSizer = AguiLabelSizer(control)
        infoText = textSizer.textCtrl
        self.infoText = infoText
        self.textSizer = textSizer

        # sizers
        control.SetSizer(controlSizer)
        controlSizer.AddSpacer((3, 3))
        controlSizer.AddSizer(textSizer, 1, wx.EXPAND)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #16
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        control.SetSizer(sizer)

        style = 0
        if aguidata.get('text_control', True):
            style = style | wx.CLRP_USE_TEXTCTRL
        if aguidata.get('show_label', False):
            style = style | wx.CLRP_SHOW_LABEL
        colorPicker = wx.ColourPickerCtrl(control, style=style)

        if aguidata.get('text_control', False):
            colorPicker.SetTextCtrlProportion(1)
#        textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT))
        sizer.Add(colorPicker, 1, flag=wx.EXPAND)
        colorPicker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.apply)
        colorPicker.Bind(wx.EVT_KILL_FOCUS, self.apply)
        self.colorPicker = colorPicker
        #        textEntry = AguiTextCtrl( window)
        #        control = textEntry

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #17
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        control.SetSizer(sizer)
        
        style = 0
        if aguidata.get('text_control', True):
            style = style | wx.CLRP_USE_TEXTCTRL
        if aguidata.get('show_label', False):
            style = style | wx.CLRP_SHOW_LABEL
        colorPicker = wx.ColourPickerCtrl( control, style=style)

        if aguidata.get('text_control', False):
            colorPicker.SetTextCtrlProportion( 1)
#        textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT))
        sizer.Add(colorPicker,1,flag=wx.EXPAND)
        colorPicker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.apply)
        colorPicker.Bind(wx.EVT_KILL_FOCUS, self.apply)
        self.colorPicker = colorPicker
#        textEntry = AguiTextCtrl( window)
#        control = textEntry

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #18
0
    def __init__(self, attribute, window, aguidata ={}, **kwargs):
        #widgets
        control = wx.Panel(window, 
                           size=(1,WX_STANDARD_HEIGHT))
        control.SetMinSize((-1, WX_STANDARD_HEIGHT))
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        control.SetSizer(controlSizer)

        try:
            rewind_image = wx.Bitmap(get_image_path("rewind.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            rewind_image = wx.ArtProvider.GetBitmap(wx.ART_UNDO,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)                             
        try:
            play_image = wx.Bitmap(get_image_path("play.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            play_image = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)                             
        try:
            pause_image = wx.Bitmap(get_image_path("pause.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            pause_image = wx.ArtProvider.GetBitmap(wx.ART_WARNING,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)                                         
        try:
            stop_image = wx.Bitmap(get_image_path("stop.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            stop_image = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)                             
        try:
            execute_image = wx.Bitmap(get_image_path("execute.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            execute_image = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)
        try:
            fast_forward_image = wx.Bitmap(get_image_path("fast_forward.png"), 
                                              wx.BITMAP_TYPE_PNG)
        except:
            fast_forward_image = wx.ArtProvider.GetBitmap(wx.ART_REDO,
                                        wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)                                         
        
        buttonOrder = ['rewind', 'play', 'pause', 'stop', 'fast_forward', 
                       'execute']
        infoDict = {
                'rewind':('Rewind', rewind_image),
                'play':('Play', play_image),
                'pause':('Pause', pause_image),
                'stop':('Stop', stop_image),
                'fast_forward':('Fast Forward', fast_forward_image),
                'execute':('Execute in separate process', execute_image),
                }
        self.functionDict = {}
        self.buttonDict = {}
        
        for item in buttonOrder:
            info = infoDict[item]
            self.buttonDict[item] = None
            if not aguidata.has_key(item):
                continue
            if isroutine(aguidata[item]):
                func = aguidata[item]
            else:
                func = getattr( window.object, aguidata[item], None)
                if not isroutine(func):
                    continue
            if item == 'play':
                button = wx.BitmapButton(control, -1, 
                                                   size=WX_BUTTON_SIZE)
                self.playbutton = button
            elif item == 'pause':
                button = wx.BitmapButton(control, -1, 
                                                   size=WX_BUTTON_SIZE)
                self.pausebutton = button
                button.Enable(False)
            else:
                button = wx.BitmapButton(control, -1, 
                                                 size=WX_BUTTON_SIZE)
            button.type = item
            self.buttonDict[item] = button
#            print info[1].Ok(), info[1]
            button.SetBitmapLabel(info[1])
            self.functionDict[button] = func    
            button.SetToolTipString(info[0])
            control.Bind(wx.EVT_BUTTON, self.button_press, button)
            controlSizer.Add( button)
        line = AguiLabelSizer(control, ' ')
        controlSizer.Add(line, 1, wx.EXPAND)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs) 
Beispiel #19
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        #widgets
        control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT))
        control.SetMinSize((-1, WX_STANDARD_HEIGHT))
        controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        control.SetSizer(controlSizer)

        try:
            rewind_image = wx.Bitmap(get_image_path("rewind.png"),
                                     wx.BITMAP_TYPE_PNG)
        except:
            rewind_image = wx.ArtProvider.GetBitmap(wx.ART_UNDO,
                                                    wx.ART_TOOLBAR,
                                                    WX_BUTTON_BMP_SIZE)
        try:
            play_image = wx.Bitmap(get_image_path("play.png"),
                                   wx.BITMAP_TYPE_PNG)
        except:
            play_image = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD,
                                                  wx.ART_TOOLBAR,
                                                  WX_BUTTON_BMP_SIZE)
        try:
            pause_image = wx.Bitmap(get_image_path("pause.png"),
                                    wx.BITMAP_TYPE_PNG)
        except:
            pause_image = wx.ArtProvider.GetBitmap(wx.ART_WARNING,
                                                   wx.ART_TOOLBAR,
                                                   WX_BUTTON_BMP_SIZE)
        try:
            stop_image = wx.Bitmap(get_image_path("stop.png"),
                                   wx.BITMAP_TYPE_PNG)
        except:
            stop_image = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK,
                                                  wx.ART_TOOLBAR,
                                                  WX_BUTTON_BMP_SIZE)
        try:
            execute_image = wx.Bitmap(get_image_path("execute.png"),
                                      wx.BITMAP_TYPE_PNG)
        except:
            execute_image = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE,
                                                     wx.ART_TOOLBAR,
                                                     WX_BUTTON_BMP_SIZE)
        try:
            fast_forward_image = wx.Bitmap(get_image_path("fast_forward.png"),
                                           wx.BITMAP_TYPE_PNG)
        except:
            fast_forward_image = wx.ArtProvider.GetBitmap(
                wx.ART_REDO, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)

        buttonOrder = [
            'rewind', 'play', 'pause', 'stop', 'fast_forward', 'execute'
        ]
        infoDict = {
            'rewind': ('Rewind', rewind_image),
            'play': ('Play', play_image),
            'pause': ('Pause', pause_image),
            'stop': ('Stop', stop_image),
            'fast_forward': ('Fast Forward', fast_forward_image),
            'execute': ('Execute in separate process', execute_image),
        }
        self.functionDict = {}
        self.buttonDict = {}

        for item in buttonOrder:
            info = infoDict[item]
            self.buttonDict[item] = None
            if not aguidata.has_key(item):
                continue
            if isroutine(aguidata[item]):
                func = aguidata[item]
            else:
                func = getattr(window.object, aguidata[item], None)
                if not isroutine(func):
                    continue
            if item == 'play':
                button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE)
                self.playbutton = button
            elif item == 'pause':
                button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE)
                self.pausebutton = button
                button.Enable(False)
            else:
                button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE)
            button.type = item
            self.buttonDict[item] = button
            #            print info[1].Ok(), info[1]
            button.SetBitmapLabel(info[1])
            self.functionDict[button] = func
            button.SetToolTipString(info[0])
            control.Bind(wx.EVT_BUTTON, self.button_press, button)
            controlSizer.Add(button)
        line = AguiLabelSizer(control, ' ')
        controlSizer.Add(line, 1, wx.EXPAND)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
Beispiel #20
0
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        #label
        label = wx.Panel(window, style=0)
        #        if not hasattr(self, 'defaultBackgroundColor'):
        #            defaultBackgroundColor = label.GetBackgroundColour()
        #            r = defaultBackgroundColor[0] - 10
        #            g = defaultBackgroundColor[1] - 10
        #            b = defaultBackgroundColor[2] - 10
        #            if r < 0: r = 0
        #            if g < 0: g = 0
        #            if b < 0: b = 0
        #            defaultBackgroundColor.Set(r,g,b)
        #            self.__class__.defaultBackgroundColor = defaultBackgroundColor
        labelAreaSizer = wx.BoxSizer(orient=wx.VERTICAL)
        textSizer = AguiLabelSizer(parent=label, line=False)
        labelAreaSizer.AddSizer(textSizer, 0, wx.TOP, 1)
        availSizer = AguiLabelSizer(parent=label,
                                    line=True,
                                    label='available:')
        availSizer.textCtrl.SetWindowStyleFlag(wx.TE_RIGHT)
        availSizer.textCtrl.SetForegroundColour('gray')
        labelAreaSizer.AddSizer(availSizer, 1, wx.EXPAND | wx.TOP, 6)
        label.SetSizer(labelAreaSizer)
        label.textCtrl = textSizer.textCtrl

        #control
        control = wx.Panel(window)
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.sizer = sizer
        #edit
        editSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        sizer.Add(editSizer, flag=wx.EXPAND)
        # list of components on object
        editList = ComponentList(parent=control, size=WX_BUTTON_SIZE)
        editList.SetToolTipString("Components attached to object")
        editList.SetPopupMinWidth(100)
        editSizer.Add(editList, 1)
        self.editList = editList
        # edit
        editButton = buttons.ThemedGenButton(control, label='Edit')
        editButton.SetInitialSize((50, self.editList.Size[1]))
        editButton.SetToolTipString("Edit this component in a new window")
        editButton.Bind(wx.EVT_BUTTON, self.edit_button_click)
        self.editButton = editButton
        editSizer.Add(editButton, 0, wx.EAST, 5)
        #delete
        bmp = wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR,
                                       WX_BUTTON_BMP_SIZE)
        removeButton = wx.BitmapButton(control,
                                       size=WX_BUTTON_SIZE,
                                       bitmap=bmp)
        removeButton.SetToolTipString("Remove this component from object")
        removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click)
        editSizer.Add(removeButton, 0)

        #add
        addSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        sizer.Add(addSizer, flag=wx.EXPAND)
        # tree of available components
        addTree = ComponentAddTree(parent=control)
        addTree.SetPopupMinWidth(150)
        addTree.SetToolTipString("Component to add")
        addSizer.Add(addTree, 1)
        self.addTree = addTree
        # add button
        addButton = buttons.ThemedGenButton(control,
                                            label='Add',
                                            style=wx.BU_EXACTFIT)
        addButton.SetInitialSize(editButton.Size)
        addButton.SetToolTipString("Add selected component")
        addButton.Bind(wx.EVT_BUTTON, self.add_button_click)
        addSizer.Add(addButton, 0, wx.EAST, 5)

        # browse button
        bmp = wx.ArtProvider.GetBitmap(wx.ART_HELP_BOOK, wx.ART_TOOLBAR,
                                       WX_BUTTON_BMP_SIZE)
        browseButton = wx.BitmapButton(control,
                                       size=WX_BUTTON_SIZE,
                                       bitmap=bmp)
        browseButton.SetToolTipString("Browse available components")
        addSizer.Add(browseButton, 0)
        browseButton.Bind(wx.EVT_BUTTON, self.open_browser)
        # won't let me size normally!?

        #growertest
        #        pane = control
        #        button = wx.Button(pane, label='fakeass')
        #        button.Bind(wx.EVT_BUTTON, self.expander_click)
        #        button2 = wx.Button(pane, label='hider')
        #        self.subButton = button2
        #        sizer.AddMany( [(button), (button2)])
        #        self.expanded = True

        control.SetSizer(sizer)
        control.SetMinSize((-1, -1))
        sizer.SetMinSize((-1, -1))
        sizer.Fit(control)
        addTree.SetMinSize((1, self.addTree.Size[1]))
        editList.SetMinSize((1, self.editList.Size[1]))

        kwargs['aguidata'] = aguidata
        kwargs['label_widget'] = label
        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, **kwargs)

        # keep the pug function around for button pressing
        # don't know if this is the right way to do it
        from pug.syswx.pugframe import PugFrame
        self.pug = PugFrame