예제 #1
0
파일: components.py 프로젝트: bcorfman/pug
    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
예제 #2
0
파일: components.py 프로젝트: bcorfman/pug
    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
예제 #3
0
파일: sound_file.py 프로젝트: bcorfman/pug
    def __init__(self, attribute, window, aguidata={}, **kw):
        aguidata['wildcards'] = "wav file (*.wav)|*.wav" \
                   "|ogg file (*.ogg)|*.ogg|"
        #                   "mp3 file (*.mp3)|*.mp3|" \
        #                   "midi files (*.mid)|*.mid|" \
        #                   "All files (*.*)|*.*"
        aguidata['subfolder'] = "sound"
        aguidata['allow_delete'] = True
        Filename.__init__(self, attribute, window, aguidata=aguidata, **kw)
        # play sound button
        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)

        playbutton = wx.BitmapButton(self.control,
                                     bitmap=play_image,
                                     size=WX_BUTTON_SIZE)
        playbutton.SetToolTipString('Play sound. Hold to loop.')
        playbutton.Bind(wx.EVT_LEFT_DOWN, self.play)
        playbutton.Bind(wx.EVT_LEFT_UP, self.stop)
        self.control.GetSizer().Add(playbutton, 0)
        self.sound = None  # currently playing sound
예제 #4
0
파일: pug_splash.py 프로젝트: bcorfman/pug
 def __init__(self, parent=None):
     # This is a recipe to a the screen.
     # Modify the following variables as necessary.
     bitmap = wx.Bitmap(get_image_path('pug.png'), wx.BITMAP_TYPE_PNG)
     splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT |\
                     wx.NO_BORDER | wx.STAY_ON_TOP
     splashDuration = 1000 # milliseconds
     # Call the constructor with the above arguments in exactly the
     # following order.
     wx.SplashScreen.__init__(self, bitmap, splashStyle,
                              splashDuration, parent)
     self.Hide()
     self.Bind(wx.EVT_CLOSE, self.OnExit)
     wx.Yield()
예제 #5
0
파일: sound_file.py 프로젝트: bcorfman/pug
    def __init__(self, attribute, window, aguidata={}, **kw):
        aguidata["wildcards"] = "wav file (*.wav)|*.wav" "|ogg file (*.ogg)|*.ogg|"
        #                   "mp3 file (*.mp3)|*.mp3|" \
        #                   "midi files (*.mid)|*.mid|" \
        #                   "All files (*.*)|*.*"
        aguidata["subfolder"] = "sound"
        aguidata["allow_delete"] = True
        Filename.__init__(self, attribute, window, aguidata=aguidata, **kw)
        # play sound button
        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)

        playbutton = wx.BitmapButton(self.control, bitmap=play_image, size=WX_BUTTON_SIZE)
        playbutton.SetToolTipString("Play sound. Hold to loop.")
        playbutton.Bind(wx.EVT_LEFT_DOWN, self.play)
        playbutton.Bind(wx.EVT_LEFT_UP, self.stop)
        self.control.GetSizer().Add(playbutton, 0)
        self.sound = None  # currently playing sound
예제 #6
0
파일: listedit.py 프로젝트: bcorfman/pug
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        #control
        control = wx.Panel(parent=window)
        sizer = wx.GridBagSizer()
        control.SetSizer(sizer)
        self.list = []
        #generate list
        self.list_generator = aguidata.get('list_generator', None)
        add = delete = info = arrange_up = arrange_down = None
        #add button
        if aguidata.get('add', False):
            addinfo = aguidata['add']
            if len(addinfo) > 0:
                addfn = addinfo[0]
            else:
                addfn = self.evt_add_button
            if len(addinfo) > 1:
                tooltip = addinfo[1]
            else:
                tooltip = "Add an item"
            add = wx.BitmapButton(control, -1, 
                                size=(WX_STANDARD_HEIGHT, WX_STANDARD_HEIGHT))
            add_image = wx.Bitmap(get_image_path("add.png"), wx.BITMAP_TYPE_PNG)
            add.SetBitmapLabel(add_image)       
            add.SetToolTipString(tooltip)
            add.Bind(wx.EVT_BUTTON, addfn)
        #delete button
        if aguidata.get('delete', False):
            deleteinfo = aguidata['delete']
            if len(deleteinfo) > 0:
                deletefn = deleteinfo[0]
            else:
                deletefn = self.evt_delete_button
            if len(deleteinfo) > 1:
                tooltip = deleteinfo[1]
            else:
                tooltip = "Delete an item"
            delete = wx.BitmapButton(control, -1, 
                                size=(WX_STANDARD_HEIGHT, WX_STANDARD_HEIGHT))
            remove_image = wx.Bitmap(get_image_path("delete.png"), 
                                     wx.BITMAP_TYPE_PNG)
            delete.SetBitmapLabel(remove_image)       
            delete.SetToolTipString(tooltip)
            delete.Bind(wx.EVT_BUTTON, deletefn)
        #info button
        if aguidata.get('info', False):
            infoinfo = aguidata['info']
            self.infotext = infoinfo[0]
            if len(infoinfo) > 1:
                tooltip = infoinfo[1]
            else:
                tooltip = "Info about this list"        
            info = wx.BitmapButton(control, -1,
                                size=(WX_STANDARD_HEIGHT, WX_STANDARD_HEIGHT))
            bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, 
                                           wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE)
            info.SetBitmapLabel(bmp)
            info.SetToolTipString(tooltip)
            info.Bind(wx.EVT_BUTTON, self.evt_info_button)
            
        #arrange buttons
        if aguidata.get('arrange_up', False):
            arrange_upinfo = aguidata['arrange_up']
            if len(arrange_upinfo) > 0:
                arrange_upfn = arrange_upinfo[0]
            else:
                arrange_upfn = self.evt_arrange_up_button
            if len(arrange_upinfo) > 1:
                tooltip = arrange_upinfo[1]
            else:
                tooltip = "Move selected item up"
            arrange_up = wx.BitmapButton(control, -1, 
                                size=(WX_STANDARD_HEIGHT, WX_STANDARD_HEIGHT/2))
            arrange_up_image = wx.Bitmap(get_image_path("arrow_up.png"), 
                                     wx.BITMAP_TYPE_PNG)
            arrange_up.SetBitmapLabel(arrange_up_image)       
            arrange_up.SetToolTipString(tooltip)
            arrange_up.Bind(wx.EVT_BUTTON, arrange_upfn)
        if aguidata.get('arrange_down', False):
            arrange_downinfo = aguidata['arrange_down']
            if len(arrange_downinfo) > 0:
                arrange_downfn = arrange_downinfo[0]
            else:
                arrange_downfn = self.evt_arrange_down_button
            if len(arrange_downinfo) > 1:
                tooltip = arrange_downinfo[1]
            else:
                tooltip = "Move selected item down"
            arrange_down = wx.BitmapButton(control, -1, 
                                size=(WX_STANDARD_HEIGHT, WX_STANDARD_HEIGHT/2))
            arrange_down_image = wx.Bitmap(get_image_path("arrow_down.png"), 
                                     wx.BITMAP_TYPE_PNG)
            arrange_down.SetBitmapLabel(arrange_down_image)       
            arrange_down.SetToolTipString(tooltip)
            arrange_down.Bind(wx.EVT_BUTTON, arrange_downfn)
        line = wx.StaticLine(control,pos=(0,0))
        line.MaxSize = (-1,1)
        buttons = 0
        defaultsize = 0
        for button in [delete, add, info, arrange_up, arrange_down]:
            if button:
                sizer.Add(button, (buttons,1))
                defaultsize += button.GetSize()[1]
                buttons+=1
        height = aguidata.get('height', defaultsize)
        control.MinSize = (-1, height+2)
        listbox = wx.ListBox(control, -1)
        listbox.MaxSize = (-1, height)
        listbox.MinSize = (-1, height)
        self.listbox = listbox
        sizer.Add(line,(buttons,0),flag=wx.EXPAND)
        sizer.Add(listbox, (0, 0),(buttons, 1), flag=wx.EXPAND | wx.EAST, 
                  border = 4)
        sizer.AddGrowableCol(0)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
예제 #7
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) 
예제 #8
0
파일: listedit.py 프로젝트: bcorfman/pug
    def __init__(self, attribute, window, aguidata={}, **kwargs):
        #control
        control = wx.Panel(parent=window)
        sizer = wx.GridBagSizer()
        control.SetSizer(sizer)
        self.list = []
        #generate list
        self.list_generator = aguidata.get('list_generator', None)
        add = delete = info = arrange_up = arrange_down = None
        #add button
        if aguidata.get('add', False):
            addinfo = aguidata['add']
            if len(addinfo) > 0:
                addfn = addinfo[0]
            else:
                addfn = self.evt_add_button
            if len(addinfo) > 1:
                tooltip = addinfo[1]
            else:
                tooltip = "Add an item"
            add = wx.BitmapButton(control,
                                  -1,
                                  size=(WX_STANDARD_HEIGHT,
                                        WX_STANDARD_HEIGHT))
            add_image = wx.Bitmap(get_image_path("add.png"),
                                  wx.BITMAP_TYPE_PNG)
            add.SetBitmapLabel(add_image)
            add.SetToolTipString(tooltip)
            add.Bind(wx.EVT_BUTTON, addfn)
        #delete button
        if aguidata.get('delete', False):
            deleteinfo = aguidata['delete']
            if len(deleteinfo) > 0:
                deletefn = deleteinfo[0]
            else:
                deletefn = self.evt_delete_button
            if len(deleteinfo) > 1:
                tooltip = deleteinfo[1]
            else:
                tooltip = "Delete an item"
            delete = wx.BitmapButton(control,
                                     -1,
                                     size=(WX_STANDARD_HEIGHT,
                                           WX_STANDARD_HEIGHT))
            remove_image = wx.Bitmap(get_image_path("delete.png"),
                                     wx.BITMAP_TYPE_PNG)
            delete.SetBitmapLabel(remove_image)
            delete.SetToolTipString(tooltip)
            delete.Bind(wx.EVT_BUTTON, deletefn)
        #info button
        if aguidata.get('info', False):
            infoinfo = aguidata['info']
            self.infotext = infoinfo[0]
            if len(infoinfo) > 1:
                tooltip = infoinfo[1]
            else:
                tooltip = "Info about this list"
            info = wx.BitmapButton(control,
                                   -1,
                                   size=(WX_STANDARD_HEIGHT,
                                         WX_STANDARD_HEIGHT))
            bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_TOOLBAR,
                                           WX_BUTTON_BMP_SIZE)
            info.SetBitmapLabel(bmp)
            info.SetToolTipString(tooltip)
            info.Bind(wx.EVT_BUTTON, self.evt_info_button)

        #arrange buttons
        if aguidata.get('arrange_up', False):
            arrange_upinfo = aguidata['arrange_up']
            if len(arrange_upinfo) > 0:
                arrange_upfn = arrange_upinfo[0]
            else:
                arrange_upfn = self.evt_arrange_up_button
            if len(arrange_upinfo) > 1:
                tooltip = arrange_upinfo[1]
            else:
                tooltip = "Move selected item up"
            arrange_up = wx.BitmapButton(control,
                                         -1,
                                         size=(WX_STANDARD_HEIGHT,
                                               WX_STANDARD_HEIGHT / 2))
            arrange_up_image = wx.Bitmap(get_image_path("arrow_up.png"),
                                         wx.BITMAP_TYPE_PNG)
            arrange_up.SetBitmapLabel(arrange_up_image)
            arrange_up.SetToolTipString(tooltip)
            arrange_up.Bind(wx.EVT_BUTTON, arrange_upfn)
        if aguidata.get('arrange_down', False):
            arrange_downinfo = aguidata['arrange_down']
            if len(arrange_downinfo) > 0:
                arrange_downfn = arrange_downinfo[0]
            else:
                arrange_downfn = self.evt_arrange_down_button
            if len(arrange_downinfo) > 1:
                tooltip = arrange_downinfo[1]
            else:
                tooltip = "Move selected item down"
            arrange_down = wx.BitmapButton(control,
                                           -1,
                                           size=(WX_STANDARD_HEIGHT,
                                                 WX_STANDARD_HEIGHT / 2))
            arrange_down_image = wx.Bitmap(get_image_path("arrow_down.png"),
                                           wx.BITMAP_TYPE_PNG)
            arrange_down.SetBitmapLabel(arrange_down_image)
            arrange_down.SetToolTipString(tooltip)
            arrange_down.Bind(wx.EVT_BUTTON, arrange_downfn)
        line = wx.StaticLine(control, pos=(0, 0))
        line.MaxSize = (-1, 1)
        buttons = 0
        defaultsize = 0
        for button in [delete, add, info, arrange_up, arrange_down]:
            if button:
                sizer.Add(button, (buttons, 1))
                defaultsize += button.GetSize()[1]
                buttons += 1
        height = aguidata.get('height', defaultsize)
        control.MinSize = (-1, height + 2)
        listbox = wx.ListBox(control, -1)
        listbox.MaxSize = (-1, height)
        listbox.MinSize = (-1, height)
        self.listbox = listbox
        sizer.Add(line, (buttons, 0), flag=wx.EXPAND)
        sizer.Add(listbox, (0, 0), (buttons, 1),
                  flag=wx.EXPAND | wx.EAST,
                  border=4)
        sizer.AddGrowableCol(0)

        kwargs['control_widget'] = control
        Base.__init__(self, attribute, window, aguidata, **kwargs)
예제 #9
0
파일: util.py 프로젝트: bcorfman/pug
def get_icon():
    "get_icon()->The wx.Icon for pug"
    return wx.Icon(get_image_path('pug.ico'), wx.BITMAP_TYPE_ICO)
예제 #10
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)
예제 #11
0
파일: util.py 프로젝트: bcorfman/pug
def get_icon():
    "get_icon()->The wx.Icon for pug"
    return wx.Icon( get_image_path('pug.ico'), wx.BITMAP_TYPE_ICO)