X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8eda5e3588fd5ef0fa91f94991e3cdc744852d3f..0967b57b85518167b93f64ccecb5a1b5dc2b2c51:/wxPython/docs/wxPythonManual.html diff --git a/wxPython/docs/wxPythonManual.html b/wxPython/docs/wxPythonManual.html index 99a49d7a54..02459a305b 100644 --- a/wxPython/docs/wxPythonManual.html +++ b/wxPython/docs/wxPythonManual.html @@ -3,12 +3,294 @@ - + The wxPython Manual - - + +
@@ -25,15 +307,15 @@ Organization: Orbtech Date: -2003-07-02 +2004-03-26 Revision: -1.2 +1.3 License:wxWindows Free Documentation Licence, Version 3 -
-

Contents

+ -
-

Introduction

+
+

Introduction

This is a guide to the wxPython GUI toolkit, written by a Python programmer for his fellow Python programmers. It began as a -simple translation of the wxWindows documentation (which is written +simple translation of the wxWidgets documentation (which is written for C++ programmers), and evolved from there. And while there's nothing wrong with C++...

Okay, you got me there. I hate C++. That's why I use Python. If you -like C++, go read the wxWindows documentation. If you'd rather read a +like C++, go read the wxWidgets documentation. If you'd rather read a guide that's written with Python programmers in mind, keep reading this one. If you like it, feel free to send me freshly roasted coffee beans, dark chocolate, and large denomination currency. Better yet, buy huge quantities of my wxPython book (written with Robin Dunn) and send one to each of your friends, relatives, and coworkers.

-
-

What is wxPython?

+
+

What is wxPython?

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 implemented as a Python extension module (native code) that wraps the -popular wxWindows cross platform GUI library, which is written in C++.

-

Like Python and wxWindows, wxPython is Open Source, which means that +popular wxWidgets cross platform GUI library, which is written in C++.

+

Like Python and wxWidgets, wxPython is Open Source, which means that it is free for anyone to use and the source code is available for anyone to look at and modify. And anyone can contribute fixes or enhnacments to the project.

@@ -126,19 +408,19 @@ or unix-like systems, and Macintosh OS X.

Since the language is Python, wxPython programs are simple, easy to write and easy to understand.

-
-

wxPython requirements

+
+

wxPython requirements

To make use of wxPython, you currently need one of the following setups.

-
-

MS-Windows

+
+

MS-Windows

  • A 486 or higher PC running MS Windows.
  • At least ?? MB of disk space.
-
-

Linux or Unix

+
+

Linux or Unix

  • Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).
  • Almost any Unix workstation, and one of: GTK+ 1.2, GTK+ 2.0, Motif @@ -146,21 +428,21 @@ setups.

  • At least ?? MB of disk space.
-
-

Mac OS X

+
+

Mac OS X

  • A PowerPC Mac running Mac OS X 10.x.
  • At least ?? MB of disk space.
-
-

What is wxWindows?

-

wxWindows is a C++ framework providing GUI (Graphical User Interface) +

+

What is wxWidgets?

+

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 Motif, and MacOS. An OS/2 port is in progress.

-

wxWindows was originally developed at the Artificial Intelligence +

wxWidgets was originally developed at the Artificial Intelligence Applications Institute, University of Edinburgh, for internal use, and was first made publicly available in 1992. Version 2 is a vastly improved version written and maintained by Julian Smart, Robert @@ -169,9 +451,9 @@ Roebling, Vadim Zeitlin, Vaclav Slavik and many others.

platforms related to Microsoft Windows, including 16-bit and 32-bit variants, unless otherwise stated. All trademarks are acknowledged.

-
-

Why another cross-platform development tool?

-

wxWindows was developed to provide a cheap and flexible way to +

+

Why another cross-platform development tool?

+

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 development, none met all of the following criteria:

@@ -181,13 +463,13 @@ development, none met all of the following criteria:

  • simplicity of programming
  • support for a wide range of compilers
  • -

    Since wxWindows was started, several other free or almost-free GUI +

    Since wxWidgets was started, several other free or almost-free GUI frameworks have emerged. However, none has the range of features, flexibility, documentation and the well-established development team -that wxWindows has.

    -

    As open source software, wxWindows has benefited from comments, ideas, +that wxWidgets has.

    +

    As open source software, wxWidgets has benefited from comments, ideas, bug fixes, enhancements and the sheer enthusiasm of users. This gives -wxWindows a certain advantage over its commercial competitors (and +wxWidgets a certain advantage over its commercial competitors (and over free libraries without an independent development team), plus a robustness against the transience of one individual or company. This openness and availability of source code is especially important when @@ -201,16 +483,16 @@ toolkits such as Motif, GTK+ and MFC.

    overstated, since GUI application development is very time-consuming, and sustained popularity of particular GUIs cannot be guaranteed. Code can very quickly become obsolete if it addresses the wrong -platform or audience. wxWindows helps to insulate the programmer from -these winds of change. Although wxWindows may not be suitable for +platform or audience. wxWidgets helps to insulate the programmer from +these winds of change. Although wxWidgets may not be suitable for every application (such as an OLE-intensive program), it provides access to most of the functionality a GUI program normally requires, plus many extras such as network programming, PostScript output, and HTML rendering; and it can of course be extended as needs dictate. As a bonus, it provides a far cleaner and easier programming interface than the native APIs. Programmers may find it worthwhile to use -wxWindows even if they are developing on only one platform.

    -

    It is impossible to sum up the functionality of wxWindows in a few +wxWidgets even if they are developing on only one platform.

    +

    It is impossible to sum up the functionality of wxWidgets in a few paragraphs, but here are some of the benefits:

    • Low cost (free, in fact!)
    • @@ -244,8 +526,8 @@ the clipboard. PNM, PCX).
    -
    -

    wxPython Overview

    +
    +

    wxPython Overview

    To set a wxPython application going, you will need to derive an App class and override App.OnInit.

    An application must have a top-level Frame or Dialog window. Each @@ -281,37 +563,37 @@ Help.

    GUI applications aren't all graphical wizardry. You'll also need lists and hash tables. But since you're working with Python, you should use the ones Python provides (list, tuple, dict), rather than -the wxWindows versions. Same goes for the database related classes. +the wxWidgets versions. Same goes for the database related classes. The basic rule of thumb is this: If you can do it directly in Python, you probably should. If there is a reason not to use a Python data -type, wxPython will provide a wrapper for the wxWindows class.

    +type, wxPython will provide a wrapper for the wxWidgets class.

    You will undoubtedly need some platform-independent file functions, and you may find it handy to maintain and search a list of paths using PathList. There's a miscellany of operating system and other functions.

    See also Classes by Category for a list of classes.

    -
    -

    Utilities and libraries supplied with wxPython

    -

    In addition to the core wxWindows library, a number of further +

    +

    Utilities and libraries supplied with wxPython

    +

    In addition to the core wxWidgets library, a number of further libraries and utilities are supplied with each distribution.

    [Need to list these.]

    -
    -

    Creating and deleting wxPython objects

    +
    +

    Creating and deleting wxPython objects

    [This section needs to be reviewed.]

    -
    -

    App overview

    +
    +

    App overview

    Classes: wx.App

    -
    -

    Application initialization

    +
    +

    Application initialization

    The OnInit method defined for a class derived from wx.App will usually create a top window as a bare minimum.

    OnInit must return a boolean value to indicate whether processing @@ -365,8 +647,8 @@ if __name__ == '__main__': main()

    -
    -

    Application shutdown

    +
    +

    Application shutdown

    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 @@ -385,11 +667,11 @@ created by the time OnExit finishes.

    [Need examples of objects needing cleanup to keep app from crashing.]

    -
    -

    Sizer overview

    +
    +

    Sizer overview

    Classes: wx.Sizer, wx.GridSizer, wx.FlexGridSizer, wx.BoxSizer, wx.StaticBoxSizer, wx.NotebookSizer, wx.CreateButtonSizer

    - +
    @@ -425,8 +707,8 @@ individual controls. Editors such as wxDesigner, wxrcedit, XRCed and wxWorkshop create dialogs based exclusively on sizers, practically forcing the user to create platform independent layouts without compromises.

    -
    -

    The idea behind sizers

    +
    +

    The idea behind sizers

    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 @@ -453,15 +735,15 @@ in a dialog or it fulfils a special task such as wrapping a static box around a dialog item (or another sizer). These sizers will be discussed one by one in the text below.

    -
    -

    Common features

    +
    +

    Common features

    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:

    -
    -

    A minimal size

    +
    +

    A minimal size

    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 @@ -472,8 +754,8 @@ thus require an explicit size. Some controls can calculate their height, but not their width (e.g. a single line text control):

    [Need graphics]

    -
    -

    A border

    +
    +

    A border

    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 @@ -482,8 +764,8 @@ samples show dialogs with only one dialog item (a button) and a border of 0, 5, and 10 pixels around the button:

    [Need graphics]

    -
    -

    An alignment

    +
    +

    An alignment

    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 @@ -494,8 +776,8 @@ three buttons in a horizontal box sizer; one button is centred, one is aligned at the top, one is aligned at the bottom:

    [Need graphics]

    -
    -

    A stretch factor

    +
    +

    A stretch factor

    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 @@ -513,8 +795,8 @@ have a stretch factor of zero and keep their initial width:

    Within wxDesigner, this stretch factor gets set from the Option menu.

    -
    -

    BoxSizer

    +
    +

    BoxSizer

    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 @@ -527,14 +809,14 @@ horizontally. The following sample shows the same dialog as in the last sample, only the box sizer is a vertical box sizer now:

    [Need graphics]

    -
    -

    StaticBoxSizer

    +
    +

    StaticBoxSizer

    StaticBoxSixer is the same as a BoxSizer, but surrounded by a static box. Here is a sample:

    [Need graphics]

    -
    -

    GridSizer

    +
    +

    GridSizer

    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 @@ -542,8 +824,8 @@ columns or the number or rows is fixed and the grid sizer will grow in the respectively other orientation if new children are added:

    [Need graphics]

    -
    -

    FlexGridSizer

    +
    +

    FlexGridSizer

    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 @@ -553,16 +835,16 @@ it requested. The following sample shows the same dialog as the one above, but using a flex grid sizer:

    [Need graphics]

    -
    -

    NotebookSizer

    +
    +

    NotebookSizer

    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.

    [Need graphics]

    -
    -

    Programming with BoxSizer

    +
    +

    Programming with BoxSizer

    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.

    @@ -601,30 +883,30 @@ wx.GROW flag is not used, the item can be aligned within available space. wx.ALIGN_LEFT, wx.ALIGN_TOP, wx.ALIGN_RIGHT, wx.ALIGN_BOTTOM, wx.ALIGN_CENTER_HORIZONTAL and wx.ALIGN_CENTER_VERTICAL do what they say. wx.ALIGN_CENTRE (same as wx.ALIGN_CENTER) is defined as -(wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL). Default -alignment is wx.ALIGN_LEFT | wx.ALIGN_TOP.

    +(wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL). Default +alignment is wx.ALIGN_LEFT | wx.ALIGN_TOP.

    As mentioned above, any window belonging to a sizer may have border, and it can be specified which of the four sides may have this border, using the wx.TOP, wx.LEFT, wx.RIGHT and wx.BOTTOM constants or wx.ALL for all directions (and you may also use wx.NORTH, wx.WEST etc instead). These flags can be used in combination with the alignment flags above as the second parameter of the Add() method using the -binary or operator (|). The sizer of the border also must be made +binary or operator (|). The sizer of the border also must be made known, and it is the third parameter in the Add() method. This means, that the entire behaviour of a sizer and its children can be controlled by the three parameters of the Add() method.

    [Show code and graphic here.]

    -
    -

    Programming with GridSizer

    +
    +

    Programming with GridSizer

    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.

    [Show code and graphic here.]

    -
    -

    Programming with FlexGridSizer

    +
    +

    Programming with FlexGridSizer

    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 @@ -632,8 +914,8 @@ rows or all columns are not necessarily the same height or width as in the GridSizer.

    [Show code and graphic here.]

    -
    -

    Programming with NotebookSizer

    +
    +

    Programming with NotebookSizer

    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 @@ -648,20 +930,20 @@ one example showing how to add a notebook page that the notebook sizer is aware of:

    [Show code and graphic here.]

    -
    -

    Programming with StaticBoxSizer

    +
    +

    Programming with StaticBoxSizer

    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.

    [Show code and graphic here.]

    -
    -

    Dialog.CreateButtonSizer

    +
    +

    Dialog.CreateButtonSizer

    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 this method:

    -
    +
    @@ -705,11 +987,11 @@ wx.OK button will be default
    -
    -

    Date and time classes overview

    +
    +

    Date and time classes overview

    wxPython provides a set of powerful classes to work with dates and times. Some of the supported features of the DateTime class are:

    - +
    @@ -737,8 +1019,8 @@ with them is fast
    -
    -

    All date/time classes at a glance

    +
    +

    All date/time classes at a glance

    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.

    @@ -748,8 +1030,8 @@ date is a holiday or not and DateTimeWorkDays which is a derivation of this class for which (only) Saturdays and Sundays are the holidays. See more about these classes in the discussion of the holidays.

    -
    -

    DateTime characteristics

    +
    +

    DateTime characteristics

    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 @@ -772,8 +1054,8 @@ country, and even region, dependent). Future versions will probably have Julian calendar support as well and support for other calendars (Maya, Hebrew, Chinese...) is not ruled out.

    -
    -

    Difference between DateSpan and TimeSpan

    +
    +

    Difference between DateSpan and TimeSpan

    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.

    @@ -801,14 +1083,14 @@ in the program, you should probably use TimeSpan instead of DateSpan in situations when you do need to understand what 'in a month' means (of course, it is just DateTime.Now() + DateSpan.Month()).

    -
    -

    Date arithmetics

    +
    +

    Date arithmetics

    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 span classes by a number is perfectly valid.

    Here is what can be done:

    - +
    @@ -838,8 +1120,8 @@ opposite time direction.
    -
    -

    Time zone considerations

    +
    +

    Time zone considerations

    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 @@ -877,8 +1159,8 @@ job. I.e. you would just write

    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());

    -
    -

    Daylight saving time (DST)

    +
    +

    Daylight saving time (DST)

    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 @@ -894,17 +1176,17 @@ the future.

    The time zone handling methods use these functions too, so they are subject to the same limitations.

    - -
    -

    Classes by category

    +
    +

    Classes by category

    Not done yet.

    -
    -

    ID constants

    +
    +

    ID constants

    wxPython provides the following predefined ID constants:

    ID_ABORT ID_ABOUT @@ -964,8 +1246,8 @@ ID_UNDO ID_YES ID_YESTOALL

    -
    -

    Source document

    +
    +

    Source document

    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 @@ -973,11 +1255,11 @@ called reStructuredText. The wxPythonManual.html file is created using the Docutils utilities, which can turn reStructuredText documents into html, xml, pdf, and even OpenOffice files.

    -
    -

    Submitting changes to the source document

    +
    +

    Submitting changes to the source document

    Some items in the source text file look like this:

    -.. This is text from the wxWindows documentation that needs to be
    +.. This is text from the wxWidgets documentation that needs to be
        translated into something appropriate for the wxPython version.
        The two dots followed by uniformly indented text turns this
        paragraph into a reStructuredText comment, so it doesn't appear
    @@ -991,8 +1273,8 @@ to you and will show my gratitude by adding your name to the list of
     contributors.  (Contributors who also send me gifts of coffee,
     chocolate, or currency will have their names listed in bold.)

    -
    -

    Contributors

    +
    +

    Contributors

    Individuals who contributed to this documentation (in order by last name):

      @@ -1003,9 +1285,9 @@ name):

    • Vadim Zeitlin
    -
    -

    License

    -

    This document began as a translation of the wxWindows documentation. +

    +

    License

    +

    This document began as a translation of the wxWidgets documentation. As such, it adheres to the same license, which is provided here:

                     wxWindows Free Documentation Licence, Version 3
    @@ -1072,9 +1354,5 @@ As such, it adheres to the same license, which is provided here:

    - -