Skip to content
Related Articles

Related Articles

Improve Article
Python – Create() function in wxPython
  • Last Updated : 10 May, 2020

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 :

ParameterInput TypeDescription
parentwx.WindowParent window. Should not be None.
idwx.WindowIDControl identifier. A value of -1 denotes a default value.
titlestringTitle to the frame.
poswx.PointWindow position.
sizewx.WindowWindow size.
stylelongWindow style.
namestringWindow 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:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :