wxPython is a GUI toolkit for Python. Over 230 classes from wxWindows are supported, so it is more complex then Tk or GTK+, but not nearly as bloated as Swing.
The developers created it using SWIG,
so polymorphism suffered a little and
it's possible to create memory leaks.
The following example tries to illustrate
object creation, window layout and event handling:
from wxPython import wx
# Creating an application object initialized the library
# Most constructors expect a parent object as the first parameter
# and an id number as second parameter.
dialog = wx.wxDialog(None, -1, "Title")
button = wx.wxButton(dialog, wx.wxID_OK, "Hello world")
# A simple way to describe a window-layout is to use sizers.
# Add a five pixel border to ALL sides and allow the button to
# EXPAND in all directions.
sizer = wx.wxBoxSizer(wx.wxHORIZONTAL)
sizer.Add(button, 1, wx.wxEXPAND|wx.wxALL, 5)
dialog.Fit() # Make the dialog as small as possible.
dialog.Layout() # Calculate the position of the button.
event.Skip() # Try to call another handler.
# Tell the dialog to call our_event_handler if the button is pressed.
wx.EVT_BUTTON(dialog, button.GetId(), our_event_handler)
dialog.Destroy() # Yes, you have to destroy dialogs explicitly. :-(