Introduction to wxPythonLast Update : 03 Nov, 2022
In this tutorial, you will learn about the basic introduction of wxPython and wxPython modules.
wxPython is a cross-platform toolkit that is used in Python GUI application development. it is used for creating desktop GUI applications. Also, You can develop applications on Windows, Mac, and various Unix systems using wxPython.The principal author of wxPython is Robin Dunn.
Basics of wxPython modules
wxPython consists of five basic modules. These modules are as follows.
This module consists of various windows used with an application. For example a Dialog, a Panel, a Frame, a Scrolled window, etc.
The meaning of GDI is Graphics Device Interface. This module contains a set of classes used for drawing widgets. Also, it contains classes for the manipulation of Fonts, Colours, Brushes, Pens, Images, etc.
This module consists of basic classes that are used in wxPython application development.
Core classes include the object class, which is the base of all classes, Sizers that are used for widget layout, events, and basic geometry classes like Rectangle and Point.
This module contains various other classes and module functions that are used for application configuration, working with display, logging, joystick, etc.
This module provides the standard widgets that are used in GUI applications. You can identify the controls under the Windows OS like a Button, a Toolbar, a Notebook, etc.
Introduction of wxPython API
wxPython API contains a set of methods and objects. In GUI applications, Widgets are the essential building block. We can identify these widgets as controls in Windows.
wxPython is a wrapper over a C++ GUI API. Therefore, it is not a native API because it is not written directly in Python.
There are lots of widgets in wxPython and also it can be divided into logical groups. These logical groups are as follows.
- Base Widgets provide basic functionality for derived widgets.
- Base Widgets are usually not used directly.
- Base Widgets are called ancestors.
The followings are examples of Base widgets.
wx.Window wx.Control wx.ControlWithItem
These widgets contain other widgets.
wx.ScrolledWindow wx.Panel wx.SplitterWindow wx.Notebook
Top-level widgets exist independently of each other widgets.
wx.Dialog wx.Frame wx.PopupWindow wx.ScrolledWindow wx.MDIParentFrame wx.MDIChiledFrame
Static widgets cannot be edited by the user. Also, It is used to display information.
wx.StaticBox wx.Gauge wx.StaticBitmap wx.StaticText wx.StaticLine
Dynamic widgets can be edited by users.
wx.ToggleButton wx.ComboBox wx.RadioButton wx.RadioBox wx.CheckBox wx.BitmapButton wx.Button wx.SpinButton wx.TextCtrl wx.Slider wx.ScrollBox wx.ListBox wx.Grid wx.SpinCtrl wx.Choice
These widgets are used to implement Statusbar, Toolbar, and Menubar in an application.
wx.ToolBar wx.MenuBar wx.StatusBar
Relations among wxPython Widgets
The concept of inheritance is an important part of object-oriented programming. wxPython uses this inheritance to make the relationship among widgets. There is a specific relation among widgets in wxPython. Also, It makes the widgets form a hierarchy.
One widget can inherit functionality from another top-level widget or widget.
Above figure show how the inheritance of a button widget in wxPython. The button widget uses different base classes to inherit their action and properties.
This is the end of the simple introduction to wxPython. In the next lesson, you can learn to develop your first wxPython GUI application.