wxPython:绘画按钮BitmapButton介绍

本节看一个绘图按钮的使用,先看看代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import wx

'''
    Function:绘图
    Input:NONE
    Output: NONE
    author: socrates
    blog:http://www.cnblogs.com/dyx1024/
    date:2012-07-20
'''  

class BitmapButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Bitmap button example",
                          size = (600, 400))
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour("blue")
        
        #创建一个绘图对象
        bmp = wx.Image("test2.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()  
        
        #绘图按钮1,默认风格3D 
        self.button = wx.BitmapButton(panel, -1, bmp, pos = (50, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()
        
        #绘图按钮1,不带边框
        self.button2 = wx.BitmapButton(panel, -1, bmp, style = 0, pos = (350, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()     
    
    def OnClick(self, event):
        self.Destroy()
        
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = BitmapButtonFrame()
    frame.Show()
    app.MainLoop()
测试:


知识点介绍:

原型:

wxBitmapButtonwxWindowparentwxWindowID idconst wxBitmapbitmapconstwxPointpos = wxDefaultPositionconst wxSizesize = wxDefaultSizelong style = wxBU_AUTODRAWconst wxValidatorvalidator = wxDefaultValidatorconst wxString&name = "button")

方法:

  • wxBitmapButton::Create
  • wxBitmapButton::GetBitmapDisabled
  • wxBitmapButton::GetBitmapFocus
  • wxBitmapButton::GetBitmapHover
  • wxBitmapButton::GetBitmapLabel
  • wxBitmapButton::GetBitmapSelected
  • wxBitmapButton::SetBitmapDisabled
  • wxBitmapButton::SetBitmapFocus
  • wxBitmapButton::SetBitmapHover
  • wxBitmapButton::SetBitmapLabel
  • wxBitmapButton::SetBitmapSelected

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值