HomeLanguageswxPyhon – BitmapButton using Create() method

wxPyhon – BitmapButton using Create() method

In this article we will learn about how we can create a BitmapButton using Create() function. Create() function is a button creation function for two-step creation. BitmapButton() constructor cannot be used for two step BitmapButton creation.
It takes different Bitmap Button attributes as parameters.

Syntax: wx.BitmapButton.Create(self, parent, id=ID_ANY, bitmap=NullBitmap, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=ButtonNameStr)

Parameters:

Parameter Input Type Description
parent wx.Window Parent window. Should not be None.
id wx.WindowID Control identifier. A value of -1 denotes a default value.
bitmap wx.Bitmap Bitto be displayed.
pos wx.Point Window position.
size wx.Window Window size.
style long Window style.
validator wx.Validator Window validator.
name string Window name.

Return Type:
bool

Code Example:




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()


Output Window:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS