Creating Frame in wxPython


Note:Use “portable python” IDE since it has wxPython by default.

import wx                      //importing the core package of wxPython

class MyApp(wx.App):           //creating a class "MyApp" instantiating the "wx.App" 
 def OnInit(self):             //constructor for the class
     myframe=wx.Frame(parent=None,title="A sample Frame")  //creating a frame(parent,title)
     myframe.Show()             //set the frame to be visible
     return True               //true if the constructor runs without errors else return false implicitly
//-------------end of the class------------------
myapp=MyApp()                  //creating an instance of MyApp class
myapp.MainLoop()               //starting a loop for dispatching  events.


This is the output

A simple frame

NOTE:Make sure you indent your python codes properly before running to prevent compilation errors!

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

One Response to Creating Frame in wxPython

  1. Nina says:

    Such a very helpful write-up. Quite interesting to learn this particular
    article.I wish to thank you for the endeavours you had created for scripting this
    article amazing post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: