📜  wxPyhon – 使用 Create() 方法的 BitmapButton

📅  最后修改于: 2022-05-13 01:55:48.597000             🧑  作者: Mango

wxPyhon – 使用 Create() 方法的 BitmapButton

在本文中,我们将了解如何使用 Create()函数创建 BitmapButton。 Create()函数是用于两步创建的按钮创建函数。 BitmapButton() 构造函数不能用于两步 BitmapButton 创建。
它以不同的 Bitmap Button 属性作为参数。

代码示例:

import wx
  
class Mywin(wx.Frame):
  
    def __init__(self, parent, title):
        super(Mywin, self).__init__(parent, title = title, size =(250, 150))
        self.InitUI()
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.panel = wx.Panel(self)
        self.btn = wx.BitmapButton()
        bmp = wx.Bitmap('right.png')
  
        # CREATE BITMAPBUTTON USING Create() function 
        self.btn.Create(self.panel, id = wx.ID_ANY, bitmap = bmp,
                          size =(bmp.GetWidth()+10, bmp.GetHeight()+10))
  
        self.SetMinSize((400, 250))
        self.Centre()
        self.Show(True)
  
  
  
ex = wx.App()
Mywin(None, 'Window')
ex.MainLoop()

输出窗口: