<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The wxPython Manual</title>
<meta name="author" content="Patrick K. O'Brien" />
<meta name="organization" content="Orbtech" />
<title>The wxPython Manual</title>
<meta name="author" content="Patrick K. O'Brien" />
<meta name="organization" content="Orbtech" />
-<div class="contents topic" id="contents">
-<p class="topic-title first"><a name="contents">Contents</a></p>
+<div class="contents topic">
+<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
<ul class="simple">
<li><a class="reference" href="#introduction" id="id1" name="id1">Introduction</a></li>
<li><a class="reference" href="#what-is-wxpython" id="id2" name="id2">What is wxPython?</a></li>
<ul class="simple">
<li><a class="reference" href="#introduction" id="id1" name="id1">Introduction</a></li>
<li><a class="reference" href="#what-is-wxpython" id="id2" name="id2">What is wxPython?</a></li>
<p>This is a guide to the wxPython GUI toolkit, written <strong>by</strong> a Python
programmer <strong>for</strong> his fellow Python programmers. It began as a
simple translation of the wxWidgets documentation (which is written
<p>This is a guide to the wxPython GUI toolkit, written <strong>by</strong> a Python
programmer <strong>for</strong> his fellow Python programmers. It began as a
simple translation of the wxWidgets documentation (which is written
buy huge quantities of my wxPython book (written with Robin Dunn) and
send one to each of your friends, relatives, and coworkers.</p>
</div>
buy huge quantities of my wxPython book (written with Robin Dunn) and
send one to each of your friends, relatives, and coworkers.</p>
</div>
<p>wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
<p>wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
<p>Since the language is Python, wxPython programs are simple, easy to
write and easy to understand.</p>
</div>
<p>Since the language is Python, wxPython programs are simple, easy to
write and easy to understand.</p>
</div>
<ul class="simple">
<li>Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).</li>
<li>Almost any Unix workstation, and one of: GTK+ 1.2, GTK+ 2.0, Motif
<ul class="simple">
<li>Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).</li>
<li>Almost any Unix workstation, and one of: GTK+ 1.2, GTK+ 2.0, Motif
<p>wxWidgets is a C++ framework providing GUI (Graphical User Interface)
and other facilities on more than one platform. Version 2 currently
supports all desktop versions of MS Windows, Unix with GTK+, Unix with
<p>wxWidgets is a C++ framework providing GUI (Graphical User Interface)
and other facilities on more than one platform. Version 2 currently
supports all desktop versions of MS Windows, Unix with GTK+, Unix with
platforms related to Microsoft Windows, including 16-bit and 32-bit
variants, unless otherwise stated. All trademarks are acknowledged.</p>
</div>
platforms related to Microsoft Windows, including 16-bit and 32-bit
variants, unless otherwise stated. All trademarks are acknowledged.</p>
</div>
-<div class="section" id="why-another-cross-platform-development-tool">
-<h1><a class="toc-backref" href="#id8" name="why-another-cross-platform-development-tool">Why another cross-platform development tool?</a></h1>
+<div class="section">
+<h1><a class="toc-backref" href="#id8" id="why-another-cross-platform-development-tool" name="why-another-cross-platform-development-tool">Why another cross-platform development tool?</a></h1>
<p>wxWidgets was developed to provide a cheap and flexible way to
maximize investment in GUI application development. While a number of
commercial class libraries already existed for cross-platform
<p>wxWidgets was developed to provide a cheap and flexible way to
maximize investment in GUI application development. While a number of
commercial class libraries already existed for cross-platform
<p>To set a wxPython application going, you will need to derive an App
class and override App.OnInit.</p>
<p>An application must have a top-level Frame or Dialog window. Each
<p>To set a wxPython application going, you will need to derive an App
class and override App.OnInit.</p>
<p>An application must have a top-level Frame or Dialog window. Each
-<div class="section" id="utilities-and-libraries-supplied-with-wxpython">
-<h1><a class="toc-backref" href="#id10" name="utilities-and-libraries-supplied-with-wxpython">Utilities and libraries supplied with wxPython</a></h1>
+<div class="section">
+<h1><a class="toc-backref" href="#id10" id="utilities-and-libraries-supplied-with-wxpython" name="utilities-and-libraries-supplied-with-wxpython">Utilities and libraries supplied with wxPython</a></h1>
<p>In addition to the core wxWidgets library, a number of further
libraries and utilities are supplied with each distribution.</p>
<p>[Need to list these.]</p>
</div>
<p>In addition to the core wxWidgets library, a number of further
libraries and utilities are supplied with each distribution.</p>
<p>[Need to list these.]</p>
</div>
<p>[This section needs to be reviewed.]</p>
<!-- In general, classes derived from wxWindow must dynamically
allocated with new and deleted with delete. If you delete a window,
<p>[This section needs to be reviewed.]</p>
<!-- In general, classes derived from wxWindow must dynamically
allocated with new and deleted with delete. If you delete a window,
that may be in use. Code that doesn't do this will probably work
fine on some platforms, and then fail under Windows. -->
</div>
that may be in use. Code that doesn't do this will probably work
fine on some platforms, and then fail under Windows. -->
</div>
<p>The OnInit method defined for a class derived from wx.App will usually
create a top window as a bare minimum.</p>
<p>OnInit must return a boolean value to indicate whether processing
<p>The OnInit method defined for a class derived from wx.App will usually
create a top window as a bare minimum.</p>
<p>OnInit must return a boolean value to indicate whether processing
<p>The application normally shuts down when the last of its top level
windows is closed. This is normally the expected behaviour and means
that it is enough to call Close() in response to the "Exit" menu
<p>The application normally shuts down when the last of its top level
windows is closed. This is normally the expected behaviour and means
that it is enough to call Close() in response to the "Exit" menu
<p>Classes: wx.Sizer, wx.GridSizer, wx.FlexGridSizer, wx.BoxSizer,
wx.StaticBoxSizer, wx.NotebookSizer, wx.CreateButtonSizer</p>
<table border="1" class="docutils">
<p>Classes: wx.Sizer, wx.GridSizer, wx.FlexGridSizer, wx.BoxSizer,
wx.StaticBoxSizer, wx.NotebookSizer, wx.CreateButtonSizer</p>
<table border="1" class="docutils">
wxWorkshop create dialogs based exclusively on sizers, practically
forcing the user to create platform independent layouts without
compromises.</p>
wxWorkshop create dialogs based exclusively on sizers, practically
forcing the user to create platform independent layouts without
compromises.</p>
<p>The layout algorithm used by sizers in wxPython is closely related to
layout systems in other GUI toolkits, such as Java's AWT, the GTK
toolkit or the Qt toolkit. It is based upon the idea of individual
<p>The layout algorithm used by sizers in wxPython is closely related to
layout systems in other GUI toolkits, such as Java's AWT, the GTK
toolkit or the Qt toolkit. It is based upon the idea of individual
around a dialog item (or another sizer). These sizers will be
discussed one by one in the text below.</p>
</div>
around a dialog item (or another sizer). These sizers will be
discussed one by one in the text below.</p>
</div>
<p>All sizers are containers, that is, they are used to lay out one
dialog item (or several dialog items), which they contain. Such items
are sometimes referred to as the children of the sizer. Independent
of how the individual sizers lay out their children, all children have
certain features in common:</p>
<p>All sizers are containers, that is, they are used to lay out one
dialog item (or several dialog items), which they contain. Such items
are sometimes referred to as the children of the sizer. Independent
of how the individual sizers lay out their children, all children have
certain features in common:</p>
<p>This minimal size is usually identical to the initial size of the
controls and may either be set explicitly in the size field of the
control constructor or may be calculated by wxPython, typically by
<p>This minimal size is usually identical to the initial size of the
controls and may either be set explicitly in the size field of the
control constructor or may be calculated by wxPython, typically by
<p>The border is just empty space and is used to separate dialog items in
a dialog. This border can either be all around, or at any combination
of sides such as only above and below the control. The thickness of
<p>The border is just empty space and is used to separate dialog items in
a dialog. This border can either be all around, or at any combination
of sides such as only above and below the control. The thickness of
<p>Often, a dialog item is given more space than its minimal size plus
its border. Depending on what flags are used for the respective dialog
item, the dialog item can be made to fill out the available space
<p>Often, a dialog item is given more space than its minimal size plus
its border. Depending on what flags are used for the respective dialog
item, the dialog item can be made to fill out the available space
<p>If a sizer contains more than one child and it is offered more space
than its children and their borders need, the question arises how to
distribute the surplus space among the children. For this purpose, a
<p>If a sizer contains more than one child and it is offered more space
than its children and their borders need, the question arises how to
distribute the surplus space among the children. For this purpose, a
<p>BoxSizer can lay out its children either vertically or horizontally,
depending on what flag is being used in its constructor. When using a
vertical sizer, each child can be centered, aligned to the right or
<p>BoxSizer can lay out its children either vertically or horizontally,
depending on what flag is being used in its constructor. When using a
vertical sizer, each child can be centered, aligned to the right or
<p>StaticBoxSixer is the same as a BoxSizer, but surrounded by a static
box. Here is a sample:</p>
<p>[Need graphics]</p>
</div>
<p>StaticBoxSixer is the same as a BoxSizer, but surrounded by a static
box. Here is a sample:</p>
<p>[Need graphics]</p>
</div>
<p>GridSizer is a two-dimensional sizer. All children are given the same
size, which is the minimal size required by the biggest child, in this
case the text control in the left bottom border. Either the number of
<p>GridSizer is a two-dimensional sizer. All children are given the same
size, which is the minimal size required by the biggest child, in this
case the text control in the left bottom border. Either the number of
<p>Another two-dimensional sizer derived from GridSizer. The width of
each column and the height of each row are calculated individually
according the minimal requirements from the respectively biggest
<p>Another two-dimensional sizer derived from GridSizer. The width of
each column and the height of each row are calculated individually
according the minimal requirements from the respectively biggest
<p>NotebookSizer can be used with notebooks. It calculates the size of
each notebook page and sets the size of the notebook to the size of
the biggest page plus some extra space required for the notebook tabs
and decorations.</p>
<p>[Need graphics]</p>
</div>
<p>NotebookSizer can be used with notebooks. It calculates the size of
each notebook page and sets the size of the notebook to the size of
the biggest page plus some extra space required for the notebook tabs
and decorations.</p>
<p>[Need graphics]</p>
</div>
<p>The basic idea behind a BoxSizer is that windows will most often be
laid out in rather simple basic geometry, typically in a row or a
column or several hierarchies of either.</p>
<p>The basic idea behind a BoxSizer is that windows will most often be
laid out in rather simple basic geometry, typically in a row or a
column or several hierarchies of either.</p>
<p>GridSizer is a sizer which lays out its children in a two-dimensional
table with all table fields having the same size, i.e. the width of
each field is the width of the widest child, the height of each field
is the height of the tallest child.</p>
<p>[Show code and graphic here.]</p>
</div>
<p>GridSizer is a sizer which lays out its children in a two-dimensional
table with all table fields having the same size, i.e. the width of
each field is the width of the widest child, the height of each field
is the height of the tallest child.</p>
<p>[Show code and graphic here.]</p>
</div>
<p>FlexGridSizer is a sizer which lays out its children in a
two-dimensional table with all table fields in one row having the same
height and all fields in one column having the same width, but all
<p>FlexGridSizer is a sizer which lays out its children in a
two-dimensional table with all table fields in one row having the same
height and all fields in one column having the same width, but all
<p>NotebookSizer is a specialized sizer to make sizers work in connection
with using notebooks. This sizer is different from any other sizer as
you must not add any children to it - instead, it queries the notebook
<p>NotebookSizer is a specialized sizer to make sizers work in connection
with using notebooks. This sizer is different from any other sizer as
you must not add any children to it - instead, it queries the notebook
<p>StaticBoxSizer is a sizer derived from BoxSizer but adds a static box
around the sizer. Note that this static box has to be created
separately.</p>
<p>[Show code and graphic here.]</p>
</div>
<p>StaticBoxSizer is a sizer derived from BoxSizer but adds a static box
around the sizer. Note that this static box has to be created
separately.</p>
<p>[Show code and graphic here.]</p>
</div>
<p>As a convenience, the Dialog class has a CreateButtonSizer(flags)
method that can be used to create a standard button sizer in which
standard buttons are displayed. The following flags can be passed to
<p>As a convenience, the Dialog class has a CreateButtonSizer(flags)
method that can be used to create a standard button sizer in which
standard buttons are displayed. The following flags can be passed to
<p>wxPython provides a set of powerful classes to work with dates and
times. Some of the supported features of the DateTime class are:</p>
<table border="1" class="docutils">
<p>wxPython provides a set of powerful classes to work with dates and
times. Some of the supported features of the DateTime class are:</p>
<table border="1" class="docutils">
<p>There are 3 main classes: except DateTime itself which represents an
absolute moment in time, there are also two classes - TimeSpan and
DateSpan which represent the intervals of time.</p>
<p>There are 3 main classes: except DateTime itself which represents an
absolute moment in time, there are also two classes - TimeSpan and
DateSpan which represent the intervals of time.</p>
this class for which (only) Saturdays and Sundays are the holidays.
See more about these classes in the discussion of the holidays.</p>
</div>
this class for which (only) Saturdays and Sundays are the holidays.
See more about these classes in the discussion of the holidays.</p>
</div>
<p>DateTime stores the time as a signed number of milliseconds since the
Epoch which is fixed, by convention, to Jan 1, 1970 - however this is
not visible to the class users (in particular, dates prior to the
<p>DateTime stores the time as a signed number of milliseconds since the
Epoch which is fixed, by convention, to Jan 1, 1970 - however this is
not visible to the class users (in particular, dates prior to the
have Julian calendar support as well and support for other calendars
(Maya, Hebrew, Chinese...) is not ruled out.</p>
</div>
have Julian calendar support as well and support for other calendars
(Maya, Hebrew, Chinese...) is not ruled out.</p>
</div>
<p>While there is only one logical way to represent an absolute moment in
the time (and hence only one DateTime class), there are at least two
methods to describe a time interval.</p>
<p>While there is only one logical way to represent an absolute moment in
the time (and hence only one DateTime class), there are at least two
methods to describe a time interval.</p>
in situations when you do need to understand what 'in a month' means
(of course, it is just DateTime.Now() + DateSpan.Month()).</p>
</div>
in situations when you do need to understand what 'in a month' means
(of course, it is just DateTime.Now() + DateSpan.Month()).</p>
</div>
<p>Many different operations may be performed with the dates, however not
all of them make sense. For example, multiplying a date by a number
is an invalid operation, even though multiplying either of the time
<p>Many different operations may be performed with the dates, however not
all of them make sense. For example, multiplying a date by a number
is an invalid operation, even though multiplying either of the time
<p>Although the time is always stored internally in GMT, you will usually
work in the local time zone. Because of this, all DateTime
constructors and setters which take the broken down date assume that
<p>Although the time is always stored internally in GMT, you will usually
work in the local time zone. Because of this, all DateTime
constructors and setters which take the broken down date assume that
printf("The time is %s in local time zone", dt.FormatTime().c_str());
printf("The time is %s in GMT", dt.FormatTime(wxDateTime::GMT).c_str());</p>
</div>
printf("The time is %s in local time zone", dt.FormatTime().c_str());
printf("The time is %s in GMT", dt.FormatTime(wxDateTime::GMT).c_str());</p>
</div>
<p>DST (a.k.a. 'summer time') handling is always a delicate task which is
better left to the operating system which is supposed to be configured
by the administrator to behave correctly. Unfortunately, when doing
<p>DST (a.k.a. 'summer time') handling is always a delicate task which is
better left to the operating system which is supposed to be configured
by the administrator to behave correctly. Unfortunately, when doing
<p>The time zone handling methods use these functions too, so they are
subject to the same limitations.</p>
</div>
<p>The time zone handling methods use these functions too, so they are
subject to the same limitations.</p>
</div>
<p>The source document is named wxPythonManual.txt and can be found by
clicking the link at the bottom of this page (assuming you are viewing
the html file). It is written using a fantastic formatting convention
<p>The source document is named wxPythonManual.txt and can be found by
clicking the link at the bottom of this page (assuming you are viewing
the html file). It is written using a fantastic formatting convention
using the Docutils utilities, which can turn reStructuredText
documents into html, xml, pdf, and even OpenOffice files.</p>
</div>
using the Docutils utilities, which can turn reStructuredText
documents into html, xml, pdf, and even OpenOffice files.</p>
</div>
<p>Some items in the source text file look like this:</p>
<pre class="literal-block">
.. This is text from the wxWidgets documentation that needs to be
<p>Some items in the source text file look like this:</p>
<pre class="literal-block">
.. This is text from the wxWidgets documentation that needs to be
contributors. (Contributors who also send me gifts of coffee,
chocolate, or currency will have their names listed in bold.)</p>
</div>
contributors. (Contributors who also send me gifts of coffee,
chocolate, or currency will have their names listed in bold.)</p>
</div>
<p>This document began as a translation of the wxWidgets documentation.
As such, it adheres to the same license, which is provided here:</p>
<pre class="literal-block">
<p>This document began as a translation of the wxWidgets documentation.
As such, it adheres to the same license, which is provided here:</p>
<pre class="literal-block">