Python wx 模块,BitmapButton() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.BitmapButton()

项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def buildToolsBar(parent, datas):    
    box = wx.BoxSizer( wx.HORIZONTAL )
    #toolsbar =  wx.ToolBar( parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TB_HORIZONTAL ) 
    toolsbar = wx.Panel( parent, wx.ID_ANY, 
                         wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )

    toolsbar.SetSizer( box )
    add_tools(toolsbar, datas[1][0][1], None)

    gifpath = os.path.join(root_dir, "tools/drop.gif")
    btn = wx.BitmapButton(toolsbar, wx.ID_ANY, make_bitmap(wx.Bitmap(gifpath)),
                          wx.DefaultPosition, (32, 32), wx.BU_AUTODRAW|wx.RAISED_BORDER)

    box.Add(btn)
    btn.Bind(wx.EVT_LEFT_DOWN, lambda x:menu_drop(parent, toolsbar, datas, btn, x))
    add_tools(toolsbar, datas[1][1][1])
    return toolsbar
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def on_delete(self, event):  # wxGlade: student_profie.<event_handler>
        self.button_delete.Disable()
        self.button_save.Disable()
        self.db_delete()
        self.clear_student_details()
        self.bitmap_photo.Enable(False)
        cur_dir=os.path.dirname(os.path.abspath((sys.argv[0])))
        path=cur_dir+"/Resources/profile_pic/"+str(self.current_admission_no)+".jpg"
        if os.path.isfile(path):
            path=cur_dir+"/Resources/profile_pic/"+str(self.current_admission_no)+".jpg"

            os.remove(path)
            path=cur_dir+"/Resources/img/browse.jpg"
            self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
            self.__set_properties()
            self.__do_layout()



        event.Skip()
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        wx.Frame.__init__(self, *args, **kwds)
        self.label_5 = wx.StaticText(self, wx.ID_ANY, "Cadena Busqueda:")
        self.text_ctrl_bucar = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_buscar = wx.Button(self, wx.ID_ANY, "Buscar")
        self.label_6 = wx.StaticText(self, wx.ID_ANY, "total VM: 333")
        self.bitmap_button_1 = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap("/home/mario/pyvmwareclient/wxglade/recicla.png", wx.BITMAP_TYPE_ANY))
        self.list_ctrl_1 = wx.ListCtrl(self, wx.ID_ANY)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent, id=wx.ID_ANY, bitmap=wx.NullBitmap, style=wx.ALIGN_LEFT, size=(-1,-1)):
        wx.BitmapButton.__init__(self, parent, id, bitmap=bitmap, style=style, size=size)
项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
def add_buttonbar(self):
        self.button_bar = wx.Panel(self)
        self.button_bar_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.button_bar, 0, wx.LEFT | wx.TOP | wx.GROW)

        for i, (mt, func) in enumerate(functions):
            bm = mathtext_to_wxbitmap(mt)
            button = wx.BitmapButton(self.button_bar, 1000 + i, bm)
            self.button_bar_sizer.Add(button, 1, wx.GROW)
            self.Bind(wx.EVT_BUTTON, self.OnChangePlot, button)

        self.button_bar.SetSizer(self.button_bar_sizer)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def build_tools(parent, toolspath):
    global host
    host = parent
    ## get tool datas from the loader.build_tools(toolspath)
    ## then generate toolsbar
    datas = loader.build_tools(toolspath)
    toolsbar = buildToolsBar(parent, datas)
    gifpath = os.path.join(root_dir, "tools/drop.gif")
    #btn = wx.BitmapButton(parent, wx.ID_ANY, wx.Bitmap(gifpath), wx.DefaultPosition, (30,30), wx.BU_AUTODRAW)
    #btn.Bind(wx.EVT_LEFT_DOWN, lambda x:menu_drop(parent, toolsbar, datas, btn, x))   
    return toolsbar#, btn
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def add_tools(bar, datas, curids=[]):
    ##! TODO: 
    ## datas? dirpath tree to generate menus/toolsbar?
    ## curids? ??
    box = bar.GetSizer() 
    if curids!=None:
        for curid in curids:
            bar.RemoveChild(curid)
            box.Hide(curid)
            box.Detach(curid)
    if curids!=None:
        del curids[:]
    for data in datas:
        btn = wx.BitmapButton(bar, wx.ID_ANY, 
                              make_bitmap(wx.Bitmap(data[1])), 
                              wx.DefaultPosition, (32,32), 
                              wx.BU_AUTODRAW|wx.RAISED_BORDER )        
        if curids!=None:
            curids.append(btn)        
        if curids==None:
            box.Add(btn)
        else: 
            box.Insert(len(box.GetChildren())-2, btn)

        btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x))
        btn.Bind( wx.EVT_ENTER_WINDOW, 
                  lambda x, p='"{}" Tool'.format(data[0].title): set_info(p))        
        if not isinstance(data[0], Macros) and issubclass(data[0], Tool):
            btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show())
        btn.SetDefault()
    box.Layout()
    bar.Refresh()
    if curids==None:
        sp = wx.StaticLine( bar, wx.ID_ANY, 
                            wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
        box.Add( sp, 0, wx.ALL|wx.EXPAND, 2 )
        box.AddStretchSpacer(1)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def reset_photo(self,default=False):

        print "changing photo"
        cur_dir=os.path.dirname(os.path.abspath((sys.argv[0])))


        if default:    


            path=cur_dir+"/Resources/img/browse.jpg"


        else:

            path=cur_dir+"/Resources/profile_pic/"+str(self.current_admission_no)+".jpg"

            if not os.path.isfile(path):

                path=cur_dir+"/Resources/img/browse.jpg"


        if self.path!=path:# changes only if it has changed
            self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))

            #self.bitmap_photo.SetBitmapSelected( wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
            selected_index=0
            print self.combo_box_adno.GetSelection()
            if self.combo_box_adno.GetSelection()>0:
                selected_index=self.combo_box_adno.GetItems().index(self.current_admission_no)
            self.__set_properties()
            self.__do_layout()
            self.combo_box_adno.SetSelection(selected_index)
            self.bitmap_photo.Enable(True)
            self.path=path
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def on_photo(self, event):  # wxGlade: student_profie.<event_handler>
        #wcd="Image Files(*.jpeg)|*.jpeg| JPG Files(*.jpg)|*.jpg| PNG Files(*.png)|*.png"
        #return 0
        print "on photo"
        wcd="Image Files(*.jpeg,*.jpg,*.png)|*.jpeg;*.jpg;*.png"
        dir = "/home"
        open_dlg = wx.FileDialog(self, message='Select Photo', defaultDir=dir, defaultFile= '', wildcard=wcd, style=wx.OPEN)
        if open_dlg.ShowModal() == wx.ID_OK:
            path = open_dlg.GetPath()

            result=self.VALID.validate_photo(path)
            if result[0]:

                self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
                self.__set_properties()
                self.__do_layout()
                self.button_save.Enable(True)
                self.prof_pic_path=path


                open_dlg.Destroy
                self.combo_box_adno.SetValue(str(self.current_admission_no))


            else:
                open_dlg.Destroy
                msg=result[1]
                icon=wx.ICON_ERROR

                dlg = wx.MessageDialog(self, msg, 'Size Error',wx.OK | wx.ICON_ERROR)                  
                dlg.ShowModal()
                dlg.Destroy()
        else:
            open_dlg.Destroy()

        event.Skip()
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: student_profie.__init__
        kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE | wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER | wx.CLIP_CHILDREN
        wx.Frame.__init__(self, *args, **kwds)
        self.panel_1 = wx.Panel(self, wx.ID_ANY, style=wx.RAISED_BORDER | wx.TAB_TRAVERSAL)
        self.combo_box_13 = wx.ComboBox(self.panel_1, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
        self.combo_box_14 = wx.ComboBox(self.panel_1, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
        self.combo_box_15 = wx.ComboBox(self.panel_1, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
        self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, _("Add New"))
        self.text_ctrl_1 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_CENTRE)
        self.bitmap_button_2 = wx.BitmapButton(self.panel_1, wx.ID_ANY, wx.Bitmap("/media/ghssvythiri/10C63D64C63D4AEC/asif/sqlite_working_aug_16/Resources/img/pass.jpg", wx.BITMAP_TYPE_ANY), style=wx.BU_AUTODRAW)
        self.static_line_1 = wx.StaticLine(self.panel_1, wx.ID_ANY)
        self.bitmap_button_1 = wx.BitmapButton(self.panel_1, wx.ID_ANY, wx.Bitmap("/media/ghssvythiri/10C63D64C63D4AEC/asif/sqlite_working_aug_16/Resources/img/exit.jpg", wx.BITMAP_TYPE_ANY))
        self.label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Name"))
        self.label_2 = wx.StaticText(self.panel_1, wx.ID_ANY, _("UID"))
        self.label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Gender"))
        self.text_ctrl_2 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_3 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.combo_box_16 = wx.ComboBox(self.panel_1, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
        self.label_4 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Date of Birth"))
        self.label_5 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Category"))
        self.label_6 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Reigion"))
        self.text_ctrl_4 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_5 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_6 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.label_7 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Caste"))
        self.label_8 = wx.StaticText(self.panel_1, wx.ID_ANY, _("First Language"))
        self.label_9 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Father"))
        self.text_ctrl_7 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_8 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_9 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.label_10 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Mother"))
        self.label_11 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Mobile"))
        self.label_12 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Email"))
        self.text_ctrl_10 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_11 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.text_ctrl_12 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
        self.hyperlink_1 = wx.HyperlinkCtrl(self.panel_1, wx.ID_ANY, "", "")
        self.hyperlink_2 = wx.HyperlinkCtrl(self.panel_1, wx.ID_ANY, "", "")
        self.hyperlink_3 = wx.HyperlinkCtrl(self.panel_1, wx.ID_ANY, "", "")
        self.static_line_2 = wx.StaticLine(self.panel_1, wx.ID_ANY)
        self.button_3 = wx.Button(self.panel_1, wx.ID_ANY, _("Delete"))
        self.button_2 = wx.Button(self.panel_1, wx.ID_ANY, _("Close"))
        self.button_4 = wx.Button(self.panel_1, wx.ID_ANY, _("Save"))

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_search, self.bitmap_button_2)
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def on_save(self, event):  # wxGlade: student_profie.<event_handler>


        if self.button_save.Label=="Edit":
            self.on_edit()
            self.button_delete.Disable()
        else:
        # if button save


            if self.text_ctrl_name.Value and self.combo_box_adno.GetValue():



                if not self.validate_all():
                    event.Skip()
                    return 0

                if self.add_flag:
                    result=self.db_insert()
                else:
                    result=self.db_update()
                if result:
                    if self.prof_pic_path!='':
                        from shutil import copyfile
                        cur_dir=os.path.dirname(os.path.abspath((sys.argv[0])))

                        dest=cur_dir+"/Resources/profile_pic/"+str(self.current_admission_no)+".jpg"

                        copyfile(self.prof_pic_path,dest)

                    self.load_admission_no()
                    self.button_save.Disable()
            else:
                msg= "Admission number and name mandatory"

                dlg = wx.MessageDialog(self, msg, '',wx.OK | wx.ICON_ERROR)                  
                dlg.ShowModal()
                dlg.Destroy()

            self.button_save.Label="Edit"
            self.set_editable(False)
            self.bitmap_photo.Enable(False)

            cur_dir=os.path.dirname(os.path.abspath((sys.argv[0])))
            path=cur_dir+"/Resources/img/browse.jpg"
            self.bitmap_photo = wx.BitmapButton(self.panel_1, wx.ID_ANY,wx.Bitmap(path, wx.BITMAP_TYPE_ANY))
            self.__set_properties()
            self.__do_layout()




        event.Skip()