六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 201|回复: 0

wxPython:绘画按钮BitmapButton介绍

[复制链接]

升级  73.33%

50

主题

50

主题

50

主题

秀才

Rank: 2

积分
160
 楼主| 发表于 2012-12-10 13:18:11 | 显示全部楼层 |阅读模式
<div id="cnblogs_post_body">本节看一个绘图按钮的使用,先看看代码:
<div class="cnblogs_code">#!/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()
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表