Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – Create() function in wx.Button

  • Last Updated : 18 Jun, 2020

In this article we are going to learn about Clear() function associated with wx.Button class of wxPython. Create() function is used for button creation function for two-step creation.

It takes attributes of a button as arguments.

Syntax: wx.Button.Create(self, parent, id=ID_ANY, label=””, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=ButtonNameStr)

Parameters:

ParameterInput TypeDescription
parentwx.WindowParent window. Should not be None.
idwx.WindowIDControl identifier. A value of -1 denotes a default value.
labelstringText Label.
poswx.PointWindow position.
sizewx.WindowWindow size.
stylelongWindow style.
validatorwx.ValidatorWindow validator.
namestringWindow name.

Return Type: bool

Code Example:




import wx
  
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        self.InitUI()
  
    def InitUI(self):
        self.pnl = wx.Panel(self)
        self.btn = wx.Button()
  
        # CREATE BUTTON USING Create() function FOR TWO STEP CREATION
        self.btn.Create(self.pnl, label ='Button', pos =(20, 20))
  
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output Window:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!