- wxPython - Drag and Drop
- wxPython - Drawing API
- Multiple Document Interface
- wxPython - Dockable Windows
- wxPython - Buttons
- wxPython - Layout Management
- wxPython - Event Handling
- wxPython - Major Classes
- wxPython - GUI Builder Tools
- wxPython - Hello World
- wxPython - Environment
- wxPython - Introduction
- wxPython - Home
wxPython Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
wxPython - Hello World
A simple GUI apppcation displaying Hello World message is built using the following steps −
Import wx module.
Define an object of Apppcation class.
Create a top level window as object of wx.Frame class. Caption and size parameters are given in constructor.
Although other controls can be added in Frame object, their layout cannot be managed. Hence, put a Panel object into the Frame.
Add a StaticText object to display ‘Hello World’ at a desired position inside the window.
Activate the frame window by show() method.
Enter the main event loop of Apppcation object.
import wx app = wx.App() window = wx.Frame(None, title = "wxPython Frame", size = (300,200)) panel = wx.Panel(window) label = wx.StaticText(panel, label = "Hello World", pos = (100,50)) window.Show(True) app.MainLoop()
The above code produces the following output −
wxFrame object is the most commonly employed top level window. It is derived from wxWindow class. A frame is a window whose size and position can be changed by the user. It has a title bar and control buttons. If required, other components pke menu bar, toolbar and status bar can be enabled. A wxFrame window can contain any frame that is not a dialog or another frame.
Advertisements