Thursday, September 4, 2025
HomeLanguagesPython – Create() function in wxPython

Python – Create() function in wxPython

In this particular article we are going to learn about Create() function present in wx.Frame class. Create function is similar to Frame() constructor of wx.Frame class. Create function is used in two-step frame construction.

Syntax :

wx.Frame.Create(parent, id=ID_ANY, title="", pos=DefaultPosition,
      size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr)

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.
title string Title to the frame.
pos wx.Point Window position.
size wx.Window Window size.
style long Window style.
name string Window name.

Code Example:




# import wxPython
import wx
  
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw)
  
        self.InitUI()
  
    def InitUI(self):
  
        pnl = wx.Panel(self)
        Button = wx.Button(pnl, label ='New Frame', pos =(20, 20))
  
        Button.Bind(wx.EVT_BUTTON, self.OnNewFrame)
  
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
  
    def OnNewFrame(self, e):
        app = wx.App()
        frm = wx.Frame()
        frm.Create(None, title ="Frame using Create()")
        frm.Show()
        app.MainLoop()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()  


Output :

Before clicking New Frame button:

After clicking New Frame button:

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

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11859 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6717 POSTS0 COMMENTS