Start updating some wx.lib docstrings

This commit is contained in:
Robin Dunn
2016-06-09 21:46:05 -07:00
parent ddfbc17469
commit dd552ce670
11 changed files with 255 additions and 274 deletions

View File

@@ -19,9 +19,9 @@ import wx.html as html
class PyClickableHtmlWindow(html.HtmlWindow): class PyClickableHtmlWindow(html.HtmlWindow):
""" """
Class for a wxHtmlWindow which responds to clicks on links by opening a Class for a :class:`wx.html.HtmlWindow` which responds to clicks on
browser pointed at that link, and to shift-clicks by copying the link links by opening a browser pointed at that link, and to shift-clicks
to the clipboard. by copying the link to the clipboard.
""" """
def __init__(self,parent,ID,**kw): def __init__(self,parent,ID,**kw):
html.HtmlWindow.__init__(self, parent, ID, **kw) html.HtmlWindow.__init__(self, parent, ID, **kw)

View File

@@ -23,7 +23,7 @@ import wx
class LayoutAnchors(wx.LayoutConstraints): class LayoutAnchors(wx.LayoutConstraints):
""" """
A class that implements Delphi's Anchors with wx.LayoutConstraints. A class that implements Delphi's Anchors with :class:`wx.LayoutConstraints`.
Anchored sides maintain the distance from the edge of the control Anchored sides maintain the distance from the edge of the control
to the same edge of the parent. When neither side is selected, to the same edge of the parent. When neither side is selected,

View File

@@ -9,7 +9,7 @@
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
""" """
A class like :class:`BusyInfo` but which doesn't take up so much space by default A class like :class:`wx.BusyInfo` but which doesn't take up so much space by default
and which has a nicer look. and which has a nicer look.
""" """
@@ -21,12 +21,12 @@ from wx.lib.stattext import GenStaticText as StaticText
class BusyInfo(object): class BusyInfo(object):
""" """
This class is just like :class:`BusyInfo`, except that its default This class is just like :class:`wx.BusyInfo`, except that its default
size is smaller, (unless the size of the message requires a larger window size is smaller, (unless the size of the message requires a larger window
size) and the background and foreground colors of the message box can be size) and the background and foreground colors of the message box can be
set. set.
Creating an instace of the class witll create an show a window with the Creating an instace of the class will create and show a window with the
given message, and when the instance is deleted then that window will be given message, and when the instance is deleted then that window will be
closed. This class also implements the context manager magic methods, so closed. This class also implements the context manager magic methods, so
it can be used with Python's `with` statement, like this:: it can be used with Python's `with` statement, like this::
@@ -41,12 +41,12 @@ class BusyInfo(object):
Create a new :class:`BusyInfo`. Create a new :class:`BusyInfo`.
:param string `msg`: a string to be displayed in the BusyInfo window. :param string `msg`: a string to be displayed in the BusyInfo window.
:param Window `parent`: an optional window to be used as the parent of :param wx.Window `parent`: an optional window to be used as the parent of
the `:class:`BusyInfo`. If given then the BusyInfo will be centered the `:class:`BusyInfo`. If given then the ``BusyInfo`` will be centered
over that window, otherwise it will be centered on the screen. over that window, otherwise it will be centered on the screen.
:param Colour `bgColour`: colour to be used for the background :param wx.Colour `bgColour`: colour to be used for the background
of the :class:`BusyInfo` of the :class:`BusyInfo`
:param Colour `fgColour`: colour to be used for the foreground (text) :param wx.Colour `fgColour`: colour to be used for the foreground (text)
of the :class:`BusyInfo` of the :class:`BusyInfo`
""" """
self.frame = _InfoFrame(parent, msg, bgColour, fgColour) self.frame = _InfoFrame(parent, msg, bgColour, fgColour)

View File

@@ -508,7 +508,7 @@ class GenButton(wx.Control):
""" """
Returns the current :class:`wx.Brush` to be used to draw the button background. Returns the current :class:`wx.Brush` to be used to draw the button background.
:param DC `dc`: the device context used to draw the button background. :param wx.DC `dc`: the device context used to draw the button background.
""" """
if self.up: if self.up:
@@ -665,9 +665,9 @@ class GenBitmapButton(GenButton):
""" """
Default class constructor. Default class constructor.
:param Window `parent`: parent window. Must not be ``None``; :param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `id`: window identifier. A value of -1 indicates a default value; :param integer `id`: window identifier. A value of -1 indicates a default value;
:param Bitmap `bitmap`: the button bitmap; :param wx.Bitmap `bitmap`: the button bitmap;
:param `pos`: the control position. A value of (-1, -1) indicates a default position, :param `pos`: the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `pos`: tuple or :class:`wx.Point` :type `pos`: tuple or :class:`wx.Point`
@@ -675,7 +675,7 @@ class GenBitmapButton(GenButton):
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `size`: tuple or :class:`wx.Size` :type `size`: tuple or :class:`wx.Size`
:param integer `style`: the button style; :param integer `style`: the button style;
:param Validator `validator`: the validator associated to the button; :param wx.Validator `validator`: the validator associated to the button;
:param string `name`: the button name. :param string `name`: the button name.
.. seealso:: :class:`wx.Button` for a list of valid window styles. .. seealso:: :class:`wx.Button` for a list of valid window styles.
@@ -740,7 +740,7 @@ class GenBitmapButton(GenButton):
""" """
Sets the bitmap for the disabled button appearance. Sets the bitmap for the disabled button appearance.
:param Bitmap `bitmap`: the bitmap for the disabled button appearance. :param wx.Bitmap `bitmap`: the bitmap for the disabled button appearance.
.. seealso:: .. seealso::
@@ -756,7 +756,7 @@ class GenBitmapButton(GenButton):
""" """
Sets the bitmap for the focused button appearance. Sets the bitmap for the focused button appearance.
:param Bitmap `bitmap`: the bitmap for the focused button appearance. :param wx.Bitmap `bitmap`: the bitmap for the focused button appearance.
.. seealso:: .. seealso::
@@ -773,7 +773,7 @@ class GenBitmapButton(GenButton):
""" """
Sets the bitmap for the selected (depressed) button appearance. Sets the bitmap for the selected (depressed) button appearance.
:param Bitmap `bitmap`: the bitmap for the selected (depressed) button appearance. :param wx.Bitmap `bitmap`: the bitmap for the selected (depressed) button appearance.
.. seealso:: .. seealso::
@@ -793,7 +793,7 @@ class GenBitmapButton(GenButton):
If `createOthers` is ``True``, then the other bitmaps will be generated If `createOthers` is ``True``, then the other bitmaps will be generated
on the fly. Currently, only the disabled bitmap is generated. on the fly. Currently, only the disabled bitmap is generated.
:param Bitmap `bitmap`: the bitmap for the normal button appearance. :param wx.Bitmap `bitmap`: the bitmap for the normal button appearance.
.. note:: This is the bitmap used for the unselected state, and for all other .. note:: This is the bitmap used for the unselected state, and for all other
states if no other bitmaps are provided. states if no other bitmaps are provided.
@@ -843,9 +843,9 @@ class GenBitmapTextButton(GenBitmapButton):
""" """
Default class constructor. Default class constructor.
:param Window `parent`: parent window. Must not be ``None``; :param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `id`: window identifier. A value of -1 indicates a default value; :param integer `id`: window identifier. A value of -1 indicates a default value;
:param Bitmap `bitmap`: the button bitmap; :param wx.Bitmap `bitmap`: the button bitmap;
:param string `label`: the button text label; :param string `label`: the button text label;
:param `pos`: the control position. A value of (-1, -1) indicates a default position, :param `pos`: the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
@@ -854,7 +854,7 @@ class GenBitmapTextButton(GenBitmapButton):
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `size`: tuple or :class:`wx.Size` :type `size`: tuple or :class:`wx.Size`
:param integer `style`: the button style; :param integer `style`: the button style;
:param Validator `validator`: the validator associated to the button; :param wx.Validator `validator`: the validator associated to the button;
:param string `name`: the button name. :param string `name`: the button name.
.. seealso:: :class:`wx.Button` for a list of valid window styles. .. seealso:: :class:`wx.Button` for a list of valid window styles.

View File

@@ -135,9 +135,9 @@ def GetMonthList():
def MakeColor(in_color): def MakeColor(in_color):
""" """
Try and create a :class:`Colour`. Try and create a :class:`wx.Colour`.
:returns: a :class:`Colour` instance to `in_colour` :returns: a :class:`wx.Colour` instance to `in_colour`
""" """
try: try:
color = wx.Colour(in_color) color = wx.Colour(in_color)
@@ -172,7 +172,7 @@ class CalDraw:
""" """
Default class constructor Default class constructor
:param Window `parent`: parent window. :param wx.Window `parent`: parent window.
""" """
self.pwidth = 1 self.pwidth = 1
@@ -221,8 +221,8 @@ class CalDraw:
""" """
Set the font and background color of the week title. Set the font and background color of the week title.
:param `font_color`: the font color, a value as is accepted by :class:`Colour` :param `font_color`: the font color, a value as is accepted by :class:`wx.Colour`
:param `week_color`: the week color, a value as is accepted by :class:`Colour` :param `week_color`: the week color, a value as is accepted by :class:`wx.Colour`
""" """
self.colors[COLOR_HEADER_FONT] = MakeColor(font_color) self.colors[COLOR_HEADER_FONT] = MakeColor(font_color)
self.colors[COLOR_HEADER_BACKGROUND] = MakeColor(week_color) self.colors[COLOR_HEADER_BACKGROUND] = MakeColor(week_color)
@@ -289,7 +289,7 @@ class CalDraw:
""" """
Draw the calendar. Draw the calendar.
:param `DC`: the :class:`DC` to use to draw on. :param `DC`: the :class:`wx.DC` to use to draw upon.
:param `sel_list`: a list of days to override the weekend highlight. :param `sel_list`: a list of days to override the weekend highlight.
""" """
self.InitScale() self.InitScale()
@@ -333,7 +333,7 @@ class CalDraw:
""" """
Draw a border around the outside of the main display rectangle. Draw a border around the outside of the main display rectangle.
:param `DC`: the :class:`DC` to use :param `DC`: the :class:`wx.DC` to use
:param `transparent`: use a transparent brush, default is ``False``. :param `transparent`: use a transparent brush, default is ``False``.
""" """
@@ -352,7 +352,7 @@ class CalDraw:
""" """
Draw the focus indicator Draw the focus indicator
:param `DC`: the :class:`DC` to use :param `DC`: the :class:`wx.DC` to use
""" """
if self.outer_border is True: if self.outer_border is True:
@@ -473,7 +473,7 @@ class CalDraw:
""" """
Draw the month and year titles. Draw the month and year titles.
:param `DC`: the :class:`DC` to use. :param `DC`: the :class:`wx.DC` to use.
""" """
month = Month[self.month] month = Month[self.month]
@@ -624,7 +624,7 @@ class CalDraw:
""" """
Draw the day numbers Draw the day numbers
:param `DC`: the :class:`DC` to use. :param `DC`: the :class:`wx.DC` to use.
""" """
f = wx.Font(10, self.fontfamily, self.fontstyle, self.fontweight) # initial font setting f = wx.Font(10, self.fontfamily, self.fontstyle, self.fontweight) # initial font setting
@@ -681,7 +681,7 @@ class CalDraw:
""" """
Draw the day text. Draw the day text.
:param `DC`: the :class:`DC` to use. :param `DC`: the :class:`wx.DC` to use.
:param `key`: the day to draw :param `key`: the day to draw
""" """
@@ -724,7 +724,7 @@ class CalDraw:
""" """
Highlight selected days. Highlight selected days.
:param `DC`: the :class:`DC` to use :param `DC`: the :class:`wx.DC` to use
""" """
for key in self.cal_sel.keys(): for key in self.cal_sel.keys():
@@ -746,7 +746,7 @@ class CalDraw:
""" """
Calculate and draw the grid lines. Calculate and draw the grid lines.
:param `DC`: the :class:`DC` to use :param `DC`: the :class:`wx.DC` to use
""" """
DC.SetPen(wx.Pen(MakeColor(self.colors[COLOR_GRID_LINES]), 0)) DC.SetPen(wx.Pen(MakeColor(self.colors[COLOR_GRID_LINES]), 0))
@@ -805,7 +805,7 @@ class CalDraw:
Set a color. Set a color.
:param `name`: the name to assign the color too. :param `name`: the name to assign the color too.
:param `value`: the color to use, see :class:`Colour` :param `value`: the color to use, see :class:`wx.Colour`
""" """
self.colors[name] = MakeColor(value) self.colors[name] = MakeColor(value)
@@ -849,16 +849,16 @@ class Calendar(wx.Control):
""" """
Default class constructor. Default class constructor.
:param Window `parent`: parent window. Must not be ``None``; :param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `id`: window identifier. A value of -1 indicates a default value; :param integer `id`: window identifier. A value of -1 indicates a default value;
:param `pos`: the control position. A value of (-1, -1) indicates a default position, :param `pos`: the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `pos`: tuple or :class:`Point` :type `pos`: tuple or :class:`wx.Point`
:param `size`: the control size. A value of (-1, -1) indicates a default size, :param `size`: the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `size`: tuple or :class:`Size` :type `size`: tuple or :class:`wx.Size`
:param integer `style`: the button style (unused); :param integer `style`: the button style (unused);
:param Validator `validator`: the validator associated to the button; :param wx.Validator `validator`: the validator associated to the button;
:param string `name`: the calendar name. :param string `name`: the calendar name.
""" """
@@ -922,7 +922,7 @@ class Calendar(wx.Control):
Set a color. Set a color.
:param `name`: the name to be assigned to the color. :param `name`: the name to be assigned to the color.
:param `value`: the color value, see :class:`Colour` for valid values :param `value`: the color value, see :class:`wx.Colour` for valid values
""" """
self.colors[name] = MakeColor(value) self.colors[name] = MakeColor(value)
@@ -1042,7 +1042,7 @@ class Calendar(wx.Control):
:param `set_size`: the control size. A value of (-1, -1) indicates a default size, :param `set_size`: the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `set_size`: tuple or :class:`Size` :type `set_size`: tuple or :class:`wx.Size`
""" """
self.size = set_size self.size = set_size
@@ -1263,7 +1263,7 @@ class Calendar(wx.Control):
""" """
Do the drawing. Do the drawing.
:param `DC`: the :class:`DC` to draw :param `DC`: the :class:`wx.DC` to draw
""" """
DC = wx.PaintDC(self) DC = wx.PaintDC(self)
@@ -1456,7 +1456,7 @@ class CalenDlg(wx.Dialog):
""" """
Default class constructor. Default class constructor.
:param Window `parent`: parent window. Must not be ``None``; :param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `month`: the month, if None the current day will be used :param integer `month`: the month, if None the current day will be used
:param integer `day`: the day :param integer `day`: the day
:param integer `year`: the year :param integer `year`: the year

View File

@@ -20,7 +20,7 @@ Description
This module loads additional colour names/values into the :class:`ColourDatabase`. This module loads additional colour names/values into the :class:`ColourDatabase`.
The :mod:`colourdb` will update the wxPython :class:`ColourDatabase` using a pre-defined The :mod:`colourdb` will update the wxPython :class:`wx.ColourDatabase` using a pre-defined
set of colour names/colour tuples, hard-coded in this module source code. set of colour names/colour tuples, hard-coded in this module source code.
@@ -722,7 +722,9 @@ def getColourInfoList():
_haveUpdated = False _haveUpdated = False
def updateColourDB(): def updateColourDB():
""" Updates the :class:`ColourDatabase` by adding new colour names and RGB values. """ """
Updates the :class:`wx.ColourDatabase` by adding new colour names and RGB values.
"""
global _haveUpdated global _haveUpdated
if not _haveUpdated: if not _haveUpdated:

View File

@@ -34,7 +34,7 @@
# #
""" """
Provides a :class:`~lib.colourselect.ColourSelect` button that, when clicked, will display a Provides a :class:`ColourSelect` button that, when clicked, will display a
colour selection dialog. colour selection dialog.
@@ -87,8 +87,8 @@ wxEVT_COMMAND_COLOURSELECT = wx.NewEventType()
class ColourSelectEvent(wx.PyCommandEvent): class ColourSelectEvent(wx.PyCommandEvent):
""" """
:class:`ColourSelectEvent` is a special subclassing of :class:`CommandEvent` and it :class:`ColourSelectEvent` is a special subclassing of :class:`wx.CommandEvent`
provides for a custom event sent every time the user chooses a colour. and it provides for a custom event sent every time the user chooses a colour.
""" """
def __init__(self, id, value): def __init__(self, id, value):
@@ -96,7 +96,7 @@ class ColourSelectEvent(wx.PyCommandEvent):
Default class constructor. Default class constructor.
:param integer `id`: the event identifier; :param integer `id`: the event identifier;
:param Colour `value`: the colour currently selected. :param wx.Colour `value`: the colour currently selected.
""" """
wx.PyCommandEvent.__init__(self, id = id) wx.PyCommandEvent.__init__(self, id = id)
@@ -120,8 +120,8 @@ EVT_COLOURSELECT = wx.PyEventBinder(wxEVT_COMMAND_COLOURSELECT, 1)
class ColourSelect(wx.BitmapButton): class ColourSelect(wx.BitmapButton):
""" """
A subclass of :class:`BitmapButton` that, when clicked, will display a colour A subclass of :class:`wx.BitmapButton` that, when clicked, will
selection dialog. display a colour selection dialog.
""" """
def __init__(self, parent, id=wx.ID_ANY, label="", colour=wx.BLACK, def __init__(self, parent, id=wx.ID_ANY, label="", colour=wx.BLACK,
@@ -130,18 +130,18 @@ class ColourSelect(wx.BitmapButton):
""" """
Default class constructor. Default class constructor.
:param Window `parent`: parent window. Must not be ``None``; :param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `id`: window identifier. A value of -1 indicates a default value; :param integer `id`: window identifier. A value of -1 indicates a default value;
:param string `label`: the button text label; :param string `label`: the button text label;
:param colour: a valid :class:`Colour` instance, which will be the default initial :param colour: a valid :class:`wx.Colour` instance, which will be the default initial
colour for this button; colour for this button;
:type `colour`: :class:`Colour` or tuple :type `colour`: :class:`wx.Colour` or tuple
:param `pos`: the control position. A value of (-1, -1) indicates a default position, :param `pos`: the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `pos`: tuple or :class:`Point` :type `pos`: tuple or :class:`wx.Point`
:param `size`: the control size. A value of (-1, -1) indicates a default size, :param `size`: the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform; chosen by either the windowing system or wxPython, depending on platform;
:type `size`: tuple or :class:`Size` :type `size`: tuple or :class:`wx.Size`
:param PyObject `callback`: a callable method/function that will be called every time :param PyObject `callback`: a callable method/function that will be called every time
the user chooses a new colour; the user chooses a new colour;
:param integer `style`: the button style. :param integer `style`: the button style.
@@ -176,7 +176,7 @@ class ColourSelect(wx.BitmapButton):
""" """
Returns the current colour set for the :class:`ColourSelect`. Returns the current colour set for the :class:`ColourSelect`.
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
""" """
return self.colour return self.colour
@@ -186,7 +186,7 @@ class ColourSelect(wx.BitmapButton):
""" """
Returns the current colour set for the :class:`ColourSelect`. Returns the current colour set for the :class:`ColourSelect`.
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
""" """
return self.colour return self.colour
@@ -197,7 +197,7 @@ class ColourSelect(wx.BitmapButton):
Sets the current colour for :class:`ColourSelect`. Sets the current colour for :class:`ColourSelect`.
:param `colour`: the new colour for :class:`ColourSelect`. :param `colour`: the new colour for :class:`ColourSelect`.
:type `colour`: tuple or string or :class:`Colour` :type `colour`: tuple or string or :class:`wx.Colour`
""" """
self.SetColour(colour) self.SetColour(colour)
@@ -208,7 +208,7 @@ class ColourSelect(wx.BitmapButton):
Sets the current colour for :class:`ColourSelect`. Sets the current colour for :class:`ColourSelect`.
:param `colour`: the new colour for :class:`ColourSelect`. :param `colour`: the new colour for :class:`ColourSelect`.
:type `colour`: tuple or string or :class:`Colour` :type `colour`: tuple or string or :class:`wx.Colour`
""" """
self.colour = wx.Colour(colour) # use the typmap or copy an existing colour object self.colour = wx.Colour(colour) # use the typmap or copy an existing colour object
@@ -271,7 +271,7 @@ class ColourSelect(wx.BitmapButton):
""" """
Sets the bitmap representation of the current selected colour to the button. Sets the bitmap representation of the current selected colour to the button.
:param Bitmap `bmp`: the new bitmap. :param wx.Bitmap `bmp`: the new bitmap.
""" """
self.SetBitmapLabel(bmp) self.SetBitmapLabel(bmp)
@@ -292,7 +292,7 @@ class ColourSelect(wx.BitmapButton):
""" """
Handles the ``wx.EVT_BUTTON`` event for :class:`ColourSelect`. Handles the ``wx.EVT_BUTTON`` event for :class:`ColourSelect`.
:param `event`: a :class:`CommandEvent` event to be processed. :param `event`: a :class:`wx.CommandEvent` event to be processed.
""" """
data = wx.ColourData() data = wx.ColourData()

View File

@@ -36,8 +36,8 @@ def AdjustAlpha(colour, alpha):
:param integer `alpha`: the new value for the colour alpha channel (between 0 :param integer `alpha`: the new value for the colour alpha channel (between 0
and 255). and 255).
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
:returns: A new :class:`Colour` with the alpha channel specified as input :returns: A new :class:`wx.Colour` with the alpha channel specified as input
""" """
return wx.Colour(colour.Red(), colour.Green(), colour.Blue(), alpha) return wx.Colour(colour.Red(), colour.Green(), colour.Blue(), alpha)
@@ -48,12 +48,12 @@ def AdjustColour(color, percent, alpha=wx.ALPHA_OPAQUE):
Brighten/darken input colour by `percent` and adjust alpha Brighten/darken input colour by `percent` and adjust alpha
channel if needed. Returns the modified color. channel if needed. Returns the modified color.
:param Colour `color`: color object to adjust; :param wx.Colour `color`: color object to adjust;
:param integer `percent`: percent to adjust +(brighten) or -(darken); :param integer `percent`: percent to adjust +(brighten) or -(darken);
:param integer `alpha`: amount to adjust alpha channel. :param integer `alpha`: amount to adjust alpha channel.
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
:returns: A new darkened/lightened :class:`Colour` with the alpha channel :returns: A new darkened/lightened :class:`wx.Colour` with the alpha channel
specified as input specified as input
""" """
@@ -76,10 +76,10 @@ def BestLabelColour(color, bw=False):
Get the best color to use for the label that will be drawn on Get the best color to use for the label that will be drawn on
top of the given color. top of the given color.
:param Colour `color`: background color that text will be drawn on; :param wx.Colour `color`: background color that text will be drawn on;
:param bool `bw`: If ``True``, only return black or white. :param bool `bw`: If ``True``, only return black or white.
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
""" """
avg = sum(color.Get()) / 3 avg = sum(color.Get()) / 3
@@ -100,7 +100,7 @@ def GetHighlightColour():
""" """
Gets the default highlight color. Gets the default highlight color.
:rtype: :class:`Colour` :rtype: :class:`wx.Colour`
""" """
if wx.Platform == '__WXMAC__': if wx.Platform == '__WXMAC__':

View File

@@ -13,12 +13,12 @@
""" """
ComboTreeBox provides a ComboBox that pops up a tree instead of a list. ComboTreeBox provides a ComboBox that pops up a tree instead of a list.
ComboTreeBox tries to provide the same interface as :class:`ComboBox` as much as ComboTreeBox tries to provide the same interface as :class:`wx.ComboBox` as much as
possible. However, whereas the ComboBox widget uses indices to access possible. However, whereas the ComboBox widget uses indices to access
items in the list of choices, ComboTreeBox uses TreeItemId's instead. If items in the list of choices, ComboTreeBox uses TreeItemId's instead. If
you add an item to the ComboTreeBox (using Append or Insert), the you add an item to the ComboTreeBox (using Append or Insert), the
:class:`TreeItemId` associated with the added item is returned. You can then use :class:`wx.TreeItemId` associated with the added item is returned. You can then use
that `TreeItemId` to add items as children of that first item. For that `wx.TreeItemId` to add items as children of that first item. For
example:: example::
from wx.lib.combotreebox import ComboTreeBox from wx.lib.combotreebox import ComboTreeBox
@@ -46,7 +46,7 @@ To get the client data of the currently selected item (if any)::
somePythonObject = combo.GetClientData(currentItem) somePythonObject = combo.GetClientData(currentItem)
Supported styles are the same as for :class:`ComboBox`, i.e. ``wx.CB_READONLY`` and Supported styles are the same as for :class:`wx.ComboBox`, i.e. ``wx.CB_READONLY`` and
``wx.CB_SORT``. Provide them as usual:: ``wx.CB_SORT``. Provide them as usual::
combo = ComboTreeBox(parent, style=wx.CB_READONLY|wx.CB_SORT) combo = ComboTreeBox(parent, style=wx.CB_READONLY|wx.CB_SORT)

View File

@@ -349,7 +349,7 @@ except AttributeError:
class MultiMessageDialog(wx.Dialog): class MultiMessageDialog(wx.Dialog):
""" """
A dialog like wx.MessageDialog, but with an optional 2nd message string A dialog like :class:`wx.MessageDialog`, but with an optional 2nd message string
that is shown in a scrolled window, and also allows passing in the icon to that is shown in a scrolled window, and also allows passing in the icon to
be shown instead of the stock error, question, etc. icons. The btnLabels be shown instead of the stock error, question, etc. icons. The btnLabels
can be used if you'd like to change the stock labels on the buttons, it's can be used if you'd like to change the stock labels on the buttons, it's
@@ -475,7 +475,7 @@ class MultiMessageDialog(wx.Dialog):
def MultiMessageBox(message, caption, msg2="", style=wx.OK, parent=None, def MultiMessageBox(message, caption, msg2="", style=wx.OK, parent=None,
icon=None, btnLabels=None): icon=None, btnLabels=None):
""" """
A function like wx.MessageBox which uses MultiMessageDialog. A function like :class:`wx.MessageBox` which uses :class:`MultiMessageDialog`.
""" """
#if not style & wx.ICON_NONE and not style & wx.ICON_MASK: #if not style & wx.ICON_NONE and not style & wx.ICON_MASK:
if not style & wx.ICON_MASK: if not style & wx.ICON_MASK:

View File

@@ -7,7 +7,7 @@
# Created: 5/15/03 # Created: 5/15/03
# Copyright: (c) 2003-2006 ActiveGrid, Inc. (Port of wxWindows classes by Julian Smart et al) # Copyright: (c) 2003-2006 ActiveGrid, Inc. (Port of wxWindows classes by Julian Smart et al)
# License: wxWindows license # License: wxWindows license
# Tags: phoenix-port # Tags: phoenix-port, docs
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@@ -78,7 +78,7 @@ class Document(wx.EvtHandler):
""" """
The document class can be used to model an application's file-based data. It The document class can be used to model an application's file-based data. It
is part of the document/view framework supported by wxWindows, and cooperates is part of the document/view framework supported by wxWindows, and cooperates
with the wxView, wxDocTemplate and wxDocManager classes. with the :class:`View`, :class:`DocTemplate` and :class:`DocManager` classes.
Note this wxPython version also keeps track of the modification date of the Note this wxPython version also keeps track of the modification date of the
document and if it changes on disk outside of the application, we will warn the document and if it changes on disk outside of the application, we will warn the
@@ -114,6 +114,7 @@ class Document(wx.EvtHandler):
method is called from the wxPython docview framework directly since method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function. wxPython does not have a virtual ProcessEvent function.
""" """
# TODO: ProcessEvent is virtual now, should this method just go away?
return False return False
@@ -148,7 +149,7 @@ class Document(wx.EvtHandler):
The document type name given to the wxDocTemplate constructor, The document type name given to the wxDocTemplate constructor,
copied to this document when the document is created. If several copied to this document when the document is created. If several
document templates are created that use the same document type, this document templates are created that use the same document type, this
variable is used in wxDocManager::CreateView to collate a list of variable is used in :meth:`DocManager.CreateView` to collate a list of
alternative view types that can be used on this kind of document. alternative view types that can be used on this kind of document.
""" """
return self._documentTypeName return self._documentTypeName
@@ -156,10 +157,10 @@ class Document(wx.EvtHandler):
def SetDocumentName(self, name): def SetDocumentName(self, name):
""" """
Sets he document type name given to the wxDocTemplate constructor, Sets the document type name given to the :class:`DocTemplate` constructor,
copied to this document when the document is created. If several copied to this document when the document is created. If several
document templates are created that use the same document type, this document templates are created that use the same document type, this
variable is used in wxDocManager::CreateView to collate a list of variable is used in :meth:`DocManager.CreateView` to collate a list of
alternative view types that can be used on this kind of document. Do alternative view types that can be used on this kind of document. Do
not change the value of this variable. not change the value of this variable.
""" """
@@ -168,16 +169,14 @@ class Document(wx.EvtHandler):
def GetDocumentSaved(self): def GetDocumentSaved(self):
""" """
Returns True if the document has been saved. This method has been Returns True if the document has been saved.
added to wxPython and is not in wxWindows.
""" """
return self._savedYet return self._savedYet
def SetDocumentSaved(self, saved=True): def SetDocumentSaved(self, saved=True):
""" """
Sets whether the document has been saved. This method has been Sets whether the document has been saved.
added to wxPython and is not in wxWindows.
""" """
self._savedYet = saved self._savedYet = saved
@@ -193,7 +192,7 @@ class Document(wx.EvtHandler):
""" """
Sets the command processor to be used for this document. The document Sets the command processor to be used for this document. The document
will then be responsible for its deletion. Normally you should not will then be responsible for its deletion. Normally you should not
call this; override OnCreateCommandProcessor instead. call this; override :meth:`OnCreateCommandProcessor` instead.
""" """
self._commandProcessor = processor self._commandProcessor = processor
@@ -213,8 +212,9 @@ class Document(wx.EvtHandler):
Call with true to mark the document as modified since the last save, Call with true to mark the document as modified since the last save,
false otherwise. You may need to override this if your document view false otherwise. You may need to override this if your document view
maintains its own record of being modified (for example if using maintains its own record of being modified (for example if using
xTextWindow to view and edit the document). :class:`wx.TextWindow` to view and edit the document).
This method has been extended to notify its views that the dirty flag has changed. This method has been extended to notify its views that the dirty
flag has changed.
""" """
self._documentModified = modify self._documentModified = modify
self.UpdateAllViews(hint=("modify", self, self._documentModified)) self.UpdateAllViews(hint=("modify", self, self._documentModified))
@@ -223,8 +223,8 @@ class Document(wx.EvtHandler):
def SetDocumentModificationDate(self): def SetDocumentModificationDate(self):
""" """
Saves the file's last modification date. Saves the file's last modification date.
This is used to check if the file has been modified outside of the application. This is used to check if the file has been modified outside of
This method has been added to wxPython and is not in wxWindows. the application.
""" """
self._documentModificationDate = os.path.getmtime(self.GetFilename()) self._documentModificationDate = os.path.getmtime(self.GetFilename())
@@ -233,7 +233,6 @@ class Document(wx.EvtHandler):
""" """
Returns the file's modification date when it was loaded from disk. Returns the file's modification date when it was loaded from disk.
This is used to check if the file has been modified outside of the application. This is used to check if the file has been modified outside of the application.
This method has been added to wxPython and is not in wxWindows.
""" """
return self._documentModificationDate return self._documentModificationDate
@@ -241,7 +240,6 @@ class Document(wx.EvtHandler):
def IsDocumentModificationDateCorrect(self): def IsDocumentModificationDateCorrect(self):
""" """
Returns False if the file has been modified outside of the application. Returns False if the file has been modified outside of the application.
This method has been added to wxPython and is not in wxWindows.
""" """
if not os.path.exists(self.GetFilename()): # document must be in memory only and can't be out of date if not os.path.exists(self.GetFilename()): # document must be in memory only and can't be out of date
return True return True
@@ -291,9 +289,9 @@ class Document(wx.EvtHandler):
def Close(self): def Close(self):
""" """
Closes the document, by calling OnSaveModified and then (if this true) Closes the document, by calling :meth:`OnSaveModified` and then (if this true)
OnCloseDocument. This does not normally delete the document object: :meth:`OnCloseDocument`. This does not normally delete the document object:
use DeleteAllViews to do this implicitly. use :meth:`DeleteAllViews` to do this implicitly.
""" """
if self.OnSaveModified(): if self.OnSaveModified():
if self.OnCloseDocument(): if self.OnCloseDocument():
@@ -306,7 +304,7 @@ class Document(wx.EvtHandler):
def OnCloseDocument(self): def OnCloseDocument(self):
""" """
The default implementation calls DeleteContents (an empty The default implementation calls :meth:`DeleteContents` (an empty
implementation) sets the modified flag to false. Override this to implementation) sets the modified flag to false. Override this to
supply additional behaviour when the document is closed with Close. supply additional behaviour when the document is closed with Close.
""" """
@@ -318,9 +316,9 @@ class Document(wx.EvtHandler):
def DeleteAllViews(self): def DeleteAllViews(self):
""" """
Calls wxView.Close and deletes each view. Deleting the final view will Calls :meth:`View.Close` and deletes each view. Deleting the final view will
implicitly delete the document itself, because the wxView destructor implicitly delete the document itself, because the wxView destructor
calls RemoveView. This in turns calls wxDocument::OnChangedViewList, calls RemoveView. This in turn calls :meth:`Document.OnChangedViewList`,
whose default implemention is to save and delete the document if no whose default implemention is to save and delete the document if no
views exist. views exist.
""" """
@@ -370,8 +368,8 @@ class Document(wx.EvtHandler):
def Save(self): def Save(self):
""" """
Saves the document by calling OnSaveDocument if there is an associated Saves the document by calling :meth:`OnSaveDocument` if there is an
filename, or SaveAs if there is no filename. associated filename, or :meth:`SaveAs` if there is no filename.
""" """
if not self.IsModified(): # and self._savedYet: This was here, but if it is not modified who cares if it hasn't been saved yet? if not self.IsModified(): # and self._savedYet: This was here, but if it is not modified who cares if it hasn't been saved yet?
return True return True
@@ -400,7 +398,7 @@ class Document(wx.EvtHandler):
def SaveAs(self): def SaveAs(self):
""" """
Prompts the user for a file to save to, and then calls OnSaveDocument. Prompts the user for a file to save to, and then calls :meth:`OnSaveDocument`.
""" """
docTemplate = self.GetDocumentTemplate() docTemplate = self.GetDocumentTemplate()
if not docTemplate: if not docTemplate:
@@ -439,9 +437,9 @@ class Document(wx.EvtHandler):
def OnSaveDocument(self, filename): def OnSaveDocument(self, filename):
""" """
Constructs an output file for the given filename (which must Constructs an output file for the given filename (which must
not be empty), and calls SaveObject. If SaveObject returns true, the not be empty), and calls :meth:`SaveObject`. If :meth:`SaveObject`
document is set to unmodified; otherwise, an error message box is returns true, the document is set to unmodified; otherwise, an
displayed. error message box is displayed.
""" """
if not filename: if not filename:
return False return False
@@ -510,7 +508,7 @@ class Document(wx.EvtHandler):
def OnOpenDocument(self, filename): def OnOpenDocument(self, filename):
""" """
Constructs an input file for the given filename (which must not Constructs an input file for the given filename (which must not
be empty), and calls LoadObject. If LoadObject returns true, the be empty), and calls :meth:`LoadObject`. If LoadObject returns true, the
document is set to unmodified; otherwise, an error message box is document is set to unmodified; otherwise, an error message box is
displayed. The document's views are notified that the filename has displayed. The document's views are notified that the filename has
changed, to give windows an opportunity to update their titles. All of changed, to give windows an opportunity to update their titles. All of
@@ -552,8 +550,8 @@ class Document(wx.EvtHandler):
def LoadObject(self, file): def LoadObject(self, file):
""" """
Override this function and call it from your own LoadObject before Override this function and call it from your own ``LoadObject`` before
loading your own data. LoadObject is called by the framework loading your own data. ``LoadObject`` is called by the framework
automatically when the document contents need to be loaded. automatically when the document contents need to be loaded.
Note that the wxPython version simply sends you a Python file object, Note that the wxPython version simply sends you a Python file object,
@@ -564,8 +562,8 @@ class Document(wx.EvtHandler):
def SaveObject(self, file): def SaveObject(self, file):
""" """
Override this function and call it from your own SaveObject before Override this function and call it from your own ``SaveObject`` before
saving your own data. SaveObject is called by the framework saving your own data. ``SaveObject`` is called by the framework
automatically when the document contents need to be saved. automatically when the document contents need to be saved.
Note that the wxPython version simply sends you a Python file object, Note that the wxPython version simply sends you a Python file object,
@@ -611,7 +609,7 @@ class Document(wx.EvtHandler):
""" """
Override this function if you want a different (or no) command Override this function if you want a different (or no) command
processor to be created when the document is created. By default, it processor to be created when the document is created. By default, it
returns an instance of wxCommandProcessor. returns an instance of :class:`CommandProcessor`.
""" """
return CommandProcessor() return CommandProcessor()
@@ -672,7 +670,7 @@ class Document(wx.EvtHandler):
def AddView(self, view): def AddView(self, view):
""" """
If the view is not already in the list of views, adds the view and If the view is not already in the list of views, adds the view and
calls OnChangedViewList. calls :meth:`OnChangedViewList`.
""" """
if not view in self._documentViews: if not view in self._documentViews:
self._documentViews.append(view) self._documentViews.append(view)
@@ -683,7 +681,7 @@ class Document(wx.EvtHandler):
def RemoveView(self, view): def RemoveView(self, view):
""" """
Removes the view from the document's list of views, and calls Removes the view from the document's list of views, and calls
OnChangedViewList. :meth:`OnChangedViewList`.
""" """
if view in self._documentViews: if view in self._documentViews:
self._documentViews.remove(view) self._documentViews.remove(view)
@@ -693,7 +691,7 @@ class Document(wx.EvtHandler):
def OnCreate(self, path, flags): def OnCreate(self, path, flags):
""" """
The default implementation calls DeleteContents (an empty The default implementation calls :meth:`DeleteContents` (an empty
implementation) sets the modified flag to false. Override this to implementation) sets the modified flag to false. Override this to
supply additional behaviour when the document is opened with Open. supply additional behaviour when the document is opened with Open.
""" """
@@ -735,7 +733,7 @@ class Document(wx.EvtHandler):
def SetFilename(self, filename, notifyViews = False): def SetFilename(self, filename, notifyViews = False):
""" """
Sets the filename for this document. Usually called by the framework. Sets the filename for this document. Usually called by the framework.
If notifyViews is true, wxView.OnChangeFilename is called for all If notifyViews is true, :meth:`View.OnChangeFilename` is called for all
views. views.
""" """
self._documentFile = filename self._documentFile = filename
@@ -747,7 +745,6 @@ class Document(wx.EvtHandler):
def GetWriteable(self): def GetWriteable(self):
""" """
Returns true if the document can be written to its accociated file path. Returns true if the document can be written to its accociated file path.
This method has been added to wxPython and is not in wxWindows.
""" """
if not self._writeable: if not self._writeable:
return False return False
@@ -759,10 +756,10 @@ class Document(wx.EvtHandler):
def SetWriteable(self, writeable): def SetWriteable(self, writeable):
""" """
Set to False if the document can not be saved. This will disable the ID_SAVE_AS Set to False if the document can not be saved. This will disable the
event and is useful for custom documents that should not be saveable. The ID_SAVE ``ID_SAVE_AS`` event and is useful for custom documents that should
event can be disabled by never Modifying the document. This method has been added not be saveable. The ``ID_SAVE`` event can be disabled by never
to wxPython and is not in wxWindows. modifying the document.
""" """
self._writeable = writeable self._writeable = writeable
@@ -771,8 +768,8 @@ class View(wx.EvtHandler):
""" """
The view class can be used to model the viewing and editing component of The view class can be used to model the viewing and editing component of
an application's file-based data. It is part of the document/view an application's file-based data. It is part of the document/view
framework supported by wxWindows, and cooperates with the wxDocument, framework supported by wxWindows, and cooperates with the :class:`Document`,
wxDocTemplate and wxDocManager classes. :class:`DocTemplate` and :class:`DocManager` classes.
""" """
def __init__(self): def __init__(self):
@@ -797,9 +794,7 @@ class View(wx.EvtHandler):
def ProcessEvent(self, event): def ProcessEvent(self, event):
""" """
Processes an event, searching event tables and calling zero or more Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
if not self.GetDocument() or not self.GetDocument().ProcessEvent(event): if not self.GetDocument() or not self.GetDocument().ProcessEvent(event):
return False return False
@@ -810,16 +805,14 @@ class View(wx.EvtHandler):
def ProcessUpdateUIEvent(self, event): def ProcessUpdateUIEvent(self, event):
""" """
Processes a UI event, searching event tables and calling zero or more Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
return False return False
def OnActivateView(self, activate, activeView, deactiveView): def OnActivateView(self, activate, activeView, deactiveView):
""" """
Called when a view is activated by means of wxView::Activate. The Called when a view is activated by means of :meth:`View.Activate`. The
default implementation does nothing. default implementation does nothing.
""" """
pass pass
@@ -844,7 +837,7 @@ class View(wx.EvtHandler):
def OnPrint(self, dc, info): def OnPrint(self, dc, info):
""" """
Override this to print the view for the printing framework. The Override this to print the view for the printing framework. The
default implementation calls View.OnDraw. default implementation calls :meth:`View.OnDraw`.
""" """
self.OnDraw(dc) self.OnDraw(dc)
@@ -852,7 +845,7 @@ class View(wx.EvtHandler):
def OnUpdate(self, sender, hint): def OnUpdate(self, sender, hint):
""" """
Called when the view should be updated. sender is a pointer to the Called when the view should be updated. sender is a pointer to the
view that sent the update request, or NULL if no single view requested view that sent the update request, or None if no single view requested
the update (for instance, when the document is opened). hint is as yet the update (for instance, when the document is opened). hint is as yet
unused but may in future contain application-specific information for unused but may in future contain application-specific information for
making updating more efficient. making updating more efficient.
@@ -906,7 +899,7 @@ class View(wx.EvtHandler):
def GetViewName(self): def GetViewName(self):
""" """
Gets the name associated with the view (passed to the wxDocTemplate Gets the name associated with the view (passed to the :class:`DocTemplate`
constructor). Not currently used by the framework. constructor). Not currently used by the framework.
""" """
return self._viewTypeName return self._viewTypeName
@@ -921,7 +914,7 @@ class View(wx.EvtHandler):
def Close(self, deleteWindow=True): def Close(self, deleteWindow=True):
""" """
Closes the view by calling OnClose. If deleteWindow is true, this Closes the view by calling :meth:`OnClose`. If deleteWindow is true, this
function should delete the window associated with the view. function should delete the window associated with the view.
""" """
if self.OnClose(deleteWindow = deleteWindow): if self.OnClose(deleteWindow = deleteWindow):
@@ -932,14 +925,14 @@ class View(wx.EvtHandler):
def Activate(self, activate=True): def Activate(self, activate=True):
""" """
Call this from your view frame's OnActivate member to tell the Call this from your view frame's ``OnActivate`` member to tell the
framework which view is currently active. If your windowing system framework which view is currently active. If your windowing system
doesn't call OnActivate, you may need to call this function from doesn't call ``OnActivate``, you may need to call this function from
OnMenuCommand or any place where you know the view must be active, and OnMenuCommand or any place where you know the view must be active, and
the framework will need to get the current view. the framework will need to get the current view.
The prepackaged view frame wxDocChildFrame calls wxView.Activate from The prepackaged view frame :class:`DocChildFrame` calls ``View.Activate` from
its OnActivate member and from its OnMenuCommand member. its ``OnActivate`` member and from its ``OnMenuCommand`` member.
""" """
if self.GetDocument() and self.GetDocumentManager(): if self.GetDocument() and self.GetDocumentManager():
self.OnActivateView(activate, self, self.GetDocumentManager().GetCurrentView()) self.OnActivateView(activate, self, self.GetDocumentManager().GetCurrentView())
@@ -949,9 +942,9 @@ class View(wx.EvtHandler):
def OnClose(self, deleteWindow=True): def OnClose(self, deleteWindow=True):
""" """
Implements closing behaviour. The default implementation calls Implements closing behaviour. The default implementation calls
wxDocument.Close to close the associated document. Does not delete the :meth:`Document.Close` to close the associated document. Does not delete the
view. The application may wish to do some cleaning up operations in view. The application may wish to do some cleaning up operations in
this function, if a call to wxDocument::Close succeeded. For example, this function, if a call to :meth:`Document::Close` succeeded. For example,
if your application's all share the same window, you need to if your application's all share the same window, you need to
disassociate the window from the view and perhaps clear the window. If disassociate the window from the view and perhaps clear the window. If
deleteWindow is true, delete the frame associated with the view. deleteWindow is true, delete the frame associated with the view.
@@ -964,10 +957,11 @@ class View(wx.EvtHandler):
def OnCreate(self, doc, flags): def OnCreate(self, doc, flags):
""" """
wxDocManager or wxDocument creates a wxView via a wxDocTemplate. Just :class:`DocManager` or :class:`Document` creates a :class:`View` via
after the wxDocTemplate creates the wxView, it calls wxView::OnCreate. a :class:`DocTemplate`. Just after the :class:`DocTemplate` creates
In its OnCreate member function, the wxView can create a the :class:`View`, it calls :meth:`xView.OnCreate`. In its ``OnCreate``
wxDocChildFrame or a derived class. This wxDocChildFrame provides user member function, the ``View`` can create a :class:`DocChildFrame` or
a derived class. This :class:`DocChildFrame` provides user
interface elements to view and/or edit the contents of the wxDocument. interface elements to view and/or edit the contents of the wxDocument.
By default, simply returns true. If the function returns false, the By default, simply returns true. If the function returns false, the
@@ -978,14 +972,14 @@ class View(wx.EvtHandler):
def OnCreatePrintout(self): def OnCreatePrintout(self):
""" """
Returns a wxPrintout object for the purposes of printing. It should Returns a :class:`wx.Printout` object for the purposes of printing. It
create a new object every time it is called; the framework will delete should create a new object every time it is called; the framework will delete
objects it creates. objects it creates.
By default, this function returns an instance of wxDocPrintout, which By default, this function returns an instance of :class:`DocPrintout`, which
prints and previews one page by calling wxView.OnDraw. prints and previews one page by calling :meth:`View.OnDraw`.
Override to return an instance of a class other than wxDocPrintout. Override to return an instance of a class other than :class:`DocPrintout`.
""" """
return DocPrintout(self, self.GetDocument().GetPrintableName()) return DocPrintout(self, self.GetDocument().GetPrintableName())
@@ -993,9 +987,9 @@ class View(wx.EvtHandler):
def GetFrame(self): def GetFrame(self):
""" """
Gets the frame associated with the view (if any). Note that this Gets the frame associated with the view (if any). Note that this
"frame" is not a wxFrame at all in the generic MDI implementation "frame" is not a :class:`wx.Frame` at all in the generic MDI implementation
which uses the notebook pages instead of the frames and this is why which uses the notebook pages instead of the frames and this is why
this method returns a wxWindow and not a wxFrame. this method returns a :class:`wx.Window` and not a :class:`wx.Frame`.
""" """
return self._viewFrame return self._viewFrame
@@ -1003,8 +997,8 @@ class View(wx.EvtHandler):
def SetFrame(self, frame): def SetFrame(self, frame):
""" """
Sets the frame associated with this view. The application should call Sets the frame associated with this view. The application should call
this if possible, to tell the view about the frame. See GetFrame for this if possible, to tell the view about the frame. See :meth:`GetFrame`
the explanation about the mismatch between the "Frame" in the method for the explanation about the mismatch between the "Frame" in the method
name and the type of its parameter. name and the type of its parameter.
""" """
self._viewFrame = frame self._viewFrame = frame
@@ -1022,7 +1016,7 @@ class View(wx.EvtHandler):
class DocTemplate(wx.Object): class DocTemplate(wx.Object):
""" """
The wxDocTemplate class is used to model the relationship between a The :class:`DocTemplate` class is used to model the relationship between a
document class and a view class. document class and a view class.
""" """
@@ -1060,13 +1054,13 @@ class DocTemplate(wx.Object):
return a new view instance on demand. return a new view instance on demand.
flags is a bit list of the following: flags is a bit list of the following:
wx.TEMPLATE_VISIBLE The template may be displayed to the user in ``TEMPLATE_VISIBLE``: The template may be displayed to the user in
dialogs. dialogs.
wx.TEMPLATE_INVISIBLE The template may not be displayed to the user in ``TEMPLATE_INVISIBLE``: The template may not be displayed to the user in
dialogs. dialogs.
wx.DEFAULT_TEMPLATE_FLAGS Defined as wxTEMPLATE_VISIBLE. ``DEFAULT_TEMPLATE_FLAGS``: Defined as ``TEMPLATE_VISIBLE``.
""" """
self._docManager = manager self._docManager = manager
self._description = description self._description = description
@@ -1178,16 +1172,14 @@ class DocTemplate(wx.Object):
def GetIcon(self): def GetIcon(self):
""" """
Returns the icon, as passed to the document template Returns the icon, as passed to the document template
constructor. This method has been added to wxPython and is constructor.
not in wxWindows.
""" """
return self._icon return self._icon
def SetIcon(self, flags): def SetIcon(self, flags):
""" """
Sets the icon. This method has been added to wxPython and is not Sets the icon.
in wxWindows.
""" """
self._icon = icon self._icon = icon
@@ -1220,8 +1212,6 @@ class DocTemplate(wx.Object):
""" """
Returns true if the document template can be shown in "New" dialogs, Returns true if the document template can be shown in "New" dialogs,
false otherwise. false otherwise.
This method has been added to wxPython and is not in wxWindows.
""" """
return (self._flags & TEMPLATE_NO_CREATE) != TEMPLATE_NO_CREATE return (self._flags & TEMPLATE_NO_CREATE) != TEMPLATE_NO_CREATE
@@ -1290,9 +1280,9 @@ class DocTemplate(wx.Object):
class DocManager(wx.EvtHandler): class DocManager(wx.EvtHandler):
""" """
The wxDocManager class is part of the document/view framework supported by The :class:`DocManager` class is part of the document/view framework,
wxWindows, and cooperates with the wxView, wxDocument and wxDocTemplate and cooperates with the :class:`View`, :class:`Document` and
classes. :class:`DocTemplate` classes.
""" """
def __init__(self, flags=DEFAULT_DOCMAN_FLAGS, initialize=True): def __init__(self, flags=DEFAULT_DOCMAN_FLAGS, initialize=True):
@@ -1362,8 +1352,7 @@ class DocManager(wx.EvtHandler):
def GetFlags(self): def GetFlags(self):
""" """
Returns the document manager's flags. This method has been Returns the document manager's flags.
added to wxPython and is not in wxWindows.
""" """
return self._flags return self._flags
@@ -1394,8 +1383,8 @@ class DocManager(wx.EvtHandler):
def Clear(self, force=True): def Clear(self, force=True):
""" """
Closes all currently opened document by callling CloseDocuments and Closes all currently opened document by callling :meth:`CloseDocuments`
clears the document manager's templates. and clears the document manager's templates.
""" """
if not self.CloseDocuments(force): if not self.CloseDocuments(force):
return False return False
@@ -1405,16 +1394,16 @@ class DocManager(wx.EvtHandler):
def Initialize(self): def Initialize(self):
""" """
Initializes data; currently just calls OnCreateFileHistory. Some data Initializes data; currently just calls :meth:`OnCreateFileHistory`. Some data
cannot always be initialized in the constructor because the programmer cannot always be initialized in the constructor because the programmer
must be given the opportunity to override functionality. In fact must be given the opportunity to override functionality. In fact
Initialize is called from the wxDocManager constructor, but this can ``Initialize`` is called from the :class:`DocManager` constructor, but this can
be vetoed by passing false to the second argument, allowing the be vetoed by passing false to the second argument, allowing the
derived class's constructor to call Initialize, possibly calling a derived class's constructor to call ``Initialize``, possibly calling a
different OnCreateFileHistory from the default. different :meth:`OnCreateFileHistory` from the default.
The bottom line: if you're not deriving from Initialize, forget it and The bottom line: if you're not deriving from ``Initialize``, forget it and
construct wxDocManager with no arguments. construct :class:`DocManager` with no arguments.
""" """
self.OnCreateFileHistory() self.OnCreateFileHistory()
return True return True
@@ -1423,7 +1412,7 @@ class DocManager(wx.EvtHandler):
def OnCreateFileHistory(self): def OnCreateFileHistory(self):
""" """
A hook to allow a derived class to create a different type of file A hook to allow a derived class to create a different type of file
history. Called from Initialize. history. Called from :meth:`Initialize`.
""" """
self._fileHistory = wx.FileHistory() self._fileHistory = wx.FileHistory()
@@ -1474,8 +1463,8 @@ class DocManager(wx.EvtHandler):
def OnFileSave(self, event): def OnFileSave(self, event):
""" """
Saves the current document by calling wxDocument.Save for the current Saves the current document by calling :meth:`Document.Save` for
document. the current document.
""" """
doc = self.GetCurrentDocument() doc = self.GetCurrentDocument()
if not doc: if not doc:
@@ -1485,7 +1474,7 @@ class DocManager(wx.EvtHandler):
def OnFileSaveAs(self, event): def OnFileSaveAs(self, event):
""" """
Calls wxDocument.SaveAs for the current document. Calls :meth:`Document.SaveAs` for the current document.
""" """
doc = self.GetCurrentDocument() doc = self.GetCurrentDocument()
if not doc: if not doc:
@@ -1495,8 +1484,8 @@ class DocManager(wx.EvtHandler):
def OnPrint(self, event): def OnPrint(self, event):
""" """
Prints the current document by calling its View's OnCreatePrintout Prints the current document by calling its View's
method. :meth:`~View.OnCreatePrintout` method.
""" """
view = self.GetCurrentView() view = self.GetCurrentView()
if not view: if not view:
@@ -1543,8 +1532,8 @@ class DocManager(wx.EvtHandler):
def OnPreview(self, event): def OnPreview(self, event):
""" """
Previews the current document by calling its View's OnCreatePrintout Previews the current document by calling its View's
method. :meth:`~View.OnCreatePrintout` method.
""" """
view = self.GetCurrentView() view = self.GetCurrentView()
if not view: if not view:
@@ -1767,9 +1756,7 @@ class DocManager(wx.EvtHandler):
def ProcessUpdateUIEvent(self, event): def ProcessUpdateUIEvent(self, event):
""" """
Processes a UI event, searching event tables and calling zero or more Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
id = event.GetId() id = event.GetId()
view = self.GetCurrentView() view = self.GetCurrentView()
@@ -1821,29 +1808,30 @@ class DocManager(wx.EvtHandler):
Creates a new document in a manner determined by the flags parameter, Creates a new document in a manner determined by the flags parameter,
which can be: which can be:
wx.lib.docview.DOC_NEW Creates a fresh document. ``wx.lib.docview.DOC_NEW`` Creates a fresh document.
wx.lib.docview.DOC_SILENT Silently loads the given document file. ``wx.lib.docview.DOC_SILENT`` Silently loads the given document file.
If wx.lib.docview.DOC_NEW is present, a new document will be created and returned, If ``wx.lib.docview.DOC_NEW`` is present, a new document will be
possibly after asking the user for a template to use if there is more created and returned, possibly after asking the user for a template to
than one document template. If wx.lib.docview.DOC_SILENT is present, a new document use if there is more than one document template. ``If
will be created and the given file loaded into it. If neither of these wx.lib.docview.DOC_SILENT`` is present, a new document will be created
flags is present, the user will be presented with a file selector for and the given file loaded into it. If neither of these flags is
the file to load, and the template to use will be determined by the present, the user will be presented with a file selector for the file
extension (Windows) or by popping up a template choice list (other to load, and the template to use will be determined by the extension
platforms). (Windows) or by popping up a template choice list (other platforms).
If the maximum number of documents has been reached, this function If the maximum number of documents has been reached, this function
will delete the oldest currently loaded document before creating a new will delete the oldest currently loaded document before creating a new
one. one.
wxPython version supports the document manager's wx.lib.docview.DOC_OPEN_ONCE wxPython version supports the document manager's
and wx.lib.docview.DOC_NO_VIEW flag. ``wx.lib.docview.DOC_OPEN_ONCE`` and ``wx.lib.docview.DOC_NO_VIEW``
flag.
if wx.lib.docview.DOC_OPEN_ONCE is present, trying to open the same file multiple if ``wx.lib.docview.DOC_OPEN_ONCE`` is present, trying to open the
times will just return the same document. same file multiple times will just return the same document. if
if wx.lib.docview.DOC_NO_VIEW is present, opening a file will generate the document, ``wx.lib.docview.DOC_NO_VIEW`` is present, opening a file will
but not generate a corresponding view. generate the document, but not generate a corresponding view.
""" """
templates = [] templates = []
for temp in self._templates: for temp in self._templates:
@@ -2123,7 +2111,8 @@ class DocManager(wx.EvtHandler):
only an approximate method of finding a template for creating a only an approximate method of finding a template for creating a
document. document.
Note this wxPython verson looks for and returns a default template if no specific template is found. Note this wxPython verson looks for and returns a default template
if no specific template is found.
""" """
default = None default = None
for temp in self._templates: for temp in self._templates:
@@ -2159,7 +2148,7 @@ class DocManager(wx.EvtHandler):
On other platforms, if there is more than one document template a On other platforms, if there is more than one document template a
choice list is popped up, followed by a file selector. choice list is popped up, followed by a file selector.
This function is used in wxDocManager.CreateDocument. This function is used in :meth:`DocManager.CreateDocument`.
""" """
if wx.Platform == "__WXMSW__" or wx.Platform == "__WXGTK__" or wx.Platform == "__WXMAC__": if wx.Platform == "__WXMSW__" or wx.Platform == "__WXGTK__" or wx.Platform == "__WXMAC__":
descr = '' descr = ''
@@ -2200,7 +2189,7 @@ class DocManager(wx.EvtHandler):
def SelectDocumentType(self, temps, sort=False): def SelectDocumentType(self, temps, sort=False):
""" """
Returns a document template by asking the user (if there is more than Returns a document template by asking the user (if there is more than
one template). This function is used in wxDocManager.CreateDocument. one template). This function is used in :methW`DocManager.CreateDocument`.
Parameters Parameters
@@ -2247,7 +2236,12 @@ class DocManager(wx.EvtHandler):
def SelectViewType(self, temps, sort=False): def SelectViewType(self, temps, sort=False):
""" """
Returns a document template by asking the user (if there is more than one template), displaying a list of valid views. This function is used in wxDocManager::CreateView. The dialog normally will not appear because the array of templates only contains those relevant to the document in question, and often there will only be one such. Returns a document template by asking the user (if there is
more than one template), displaying a list of valid views.
This function is used in wxDocManager::CreateView. The dialog
normally will not appear because the array of templates only
contains those relevant to the document in question, and
often there will only be one such.
""" """
templates = [] templates = []
strings = [] strings = []
@@ -2278,8 +2272,7 @@ class DocManager(wx.EvtHandler):
def GetTemplates(self): def GetTemplates(self):
""" """
Returns the document manager's template list. This method has been added to Returns the document manager's template list.
wxPython and is not in wxWindows.
""" """
return self._templates return self._templates
@@ -2354,15 +2347,17 @@ class DocManager(wx.EvtHandler):
class DocParentFrame(wx.Frame): class DocParentFrame(wx.Frame):
""" """
The wxDocParentFrame class provides a default top-level frame for The :class:`DocParentFrame` class provides a default top-level frame for
applications using the document/view framework. This class can only be applications using the document/view framework. This class can only be
used for SDI (not MDI) parent frames. used for SDI (not MDI) parent frames.
It cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplates It cooperates with the :class:`View`, :class:`Document`, :class:`DocManager`
classes. and :class:`DocTemplates` classes.
""" """
def __init__(self, manager, frame, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="frame"): def __init__(self, manager, frame, id, title, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE,
name="frame"):
""" """
Constructor. Note that the event table must be rebuilt for the Constructor. Note that the event table must be rebuilt for the
frame since the EvtHandler is not virtual. frame since the EvtHandler is not virtual.
@@ -2405,9 +2400,7 @@ class DocParentFrame(wx.Frame):
def ProcessEvent(self, event): def ProcessEvent(self, event):
""" """
Processes an event, searching event tables and calling zero or more Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
return self._docManager and self._docManager.ProcessEvent(event) return self._docManager and self._docManager.ProcessEvent(event)
@@ -2415,9 +2408,7 @@ class DocParentFrame(wx.Frame):
def ProcessUpdateUIEvent(self, event): def ProcessUpdateUIEvent(self, event):
""" """
Processes a UI event, searching event tables and calling zero or more Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
return self._docManager and self._docManager.ProcessUpdateUIEvent(event) return self._docManager and self._docManager.ProcessUpdateUIEvent(event)
@@ -2462,20 +2453,19 @@ class DocParentFrame(wx.Frame):
class DocChildFrame(wx.Frame): class DocChildFrame(wx.Frame):
""" """
The wxDocChildFrame class provides a default frame for displaying The :class:`DocChildFrame` class provides a default frame for displaying
documents on separate windows. This class can only be used for SDI (not documents on separate windows. This class can only be used for SDI (not
MDI) child frames. MDI) child frames.
The class is part of the document/view framework supported by wxWindows, The class is part of the document/view framework and cooperates with
and cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplate the :class:`View`, :class:`Document`, :class:`DocManager` and
classes. :class:`DocTemplate` classes.
""" """
def __init__(self, doc, view, frame, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="frame"): def __init__(self, doc, view, frame, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="frame"):
""" """
Constructor. Note that the event table must be rebuilt for the Constructor.
frame since the EvtHandler is not virtual.
""" """
wx.Frame.__init__(self, frame, id, title, pos, size, style, name) wx.Frame.__init__(self, frame, id, title, pos, size, style, name)
wx.EVT_ACTIVATE(self, self.OnActivate) wx.EVT_ACTIVATE(self, self.OnActivate)
@@ -2515,9 +2505,7 @@ class DocChildFrame(wx.Frame):
def ProcessEvent(self, event): def ProcessEvent(self, event):
""" """
Processes an event, searching event tables and calling zero or more Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
if self._childView: if self._childView:
self._childView.Activate(True) self._childView.Activate(True)
@@ -2535,9 +2523,7 @@ class DocChildFrame(wx.Frame):
def ProcessUpdateUIEvent(self, event): def ProcessUpdateUIEvent(self, event):
""" """
Processes a UI event, searching event tables and calling zero or more Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
if self.GetParent(): if self.GetParent():
self.GetParent().ProcessUpdateUIEvent(event) self.GetParent().ProcessUpdateUIEvent(event)
@@ -2609,19 +2595,18 @@ class DocChildFrame(wx.Frame):
class DocMDIParentFrame(wx.MDIParentFrame): class DocMDIParentFrame(wx.MDIParentFrame):
""" """
The wxDocMDIParentFrame class provides a default top-level frame for The :class:`DocMDIParentFrame` class provides a default top-level frame for
applications using the document/view framework. This class can only be applications using the document/view framework. This class can only be
used for MDI parent frames. used for MDI parent frames.
It cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplate It cooperates with the :class:`View`, :class:`Document`,
classes. :class:`DocManager` and :class:`DocTemplate` classes.
""" """
def __init__(self, manager, frame, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="frame"): def __init__(self, manager, frame, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="frame"):
""" """
Constructor. Note that the event table must be rebuilt for the Constructor.
frame since the EvtHandler is not virtual.
""" """
wx.MDIParentFrame.__init__(self, frame, id, title, pos, size, style, name) wx.MDIParentFrame.__init__(self, frame, id, title, pos, size, style, name)
self._docManager = manager self._docManager = manager
@@ -2661,9 +2646,7 @@ class DocMDIParentFrame(wx.MDIParentFrame):
def ProcessEvent(self, event): def ProcessEvent(self, event):
""" """
Processes an event, searching event tables and calling zero or more Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
return self._docManager and self._docManager.ProcessEvent(event) return self._docManager and self._docManager.ProcessEvent(event)
@@ -2671,9 +2654,7 @@ class DocMDIParentFrame(wx.MDIParentFrame):
def ProcessUpdateUIEvent(self, event): def ProcessUpdateUIEvent(self, event):
""" """
Processes a UI event, searching event tables and calling zero or more Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
return self._docManager and self._docManager.ProcessUpdateUIEvent(event) return self._docManager and self._docManager.ProcessUpdateUIEvent(event)
@@ -2718,12 +2699,12 @@ class DocMDIParentFrame(wx.MDIParentFrame):
class DocMDIChildFrame(wx.MDIChildFrame): class DocMDIChildFrame(wx.MDIChildFrame):
""" """
The wxDocMDIChildFrame class provides a default frame for displaying The :class:`DocMDIChildFrame` class provides a default frame for displaying
documents on separate windows. This class can only be used for MDI child documents on separate windows. This class can only be used for MDI child
frames. frames.
The class is part of the document/view framework supported by wxWindows, The class is part of the document/view framework and cooperates with the
and cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplate :class:`View`, :class:`Document`, :class:`DocManager` and :class:`DocTemplate`
classes. classes.
""" """
@@ -2773,9 +2754,7 @@ class DocMDIChildFrame(wx.MDIChildFrame):
def ProcessEvent(event): def ProcessEvent(event):
""" """
Processes an event, searching event tables and calling zero or more Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent suitable event handler function(s).
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
""" """
if self._activeEvent == event: if self._activeEvent == event:
return False return False
@@ -2872,7 +2851,6 @@ class DocMDIChildFrame(wx.MDIChildFrame):
""" """
Add/remove to the frame's title an indication that the document is dirty. Add/remove to the frame's title an indication that the document is dirty.
If the document is dirty, an '*' is appended to the title If the document is dirty, an '*' is appended to the title
This method has been added to wxPython and is not in wxWindows.
""" """
title = self.GetTitle() title = self.GetTitle()
if title: if title:
@@ -2892,8 +2870,8 @@ class DocMDIChildFrame(wx.MDIChildFrame):
class DocPrintout(wx.Printout): class DocPrintout(wx.Printout):
""" """
DocPrintout is a default Printout that prints the first page of a document DocPrintout is a default :class:`wx.Printout` that prints the first
view. page of a document view.
""" """
@@ -2953,24 +2931,24 @@ class DocPrintout(wx.Printout):
class Command(wx.Object): class Command(wx.Object):
""" """
wxCommand is a base class for modelling an application command, which is ``Command`` is a base class for modelling an application command,
an action usually performed by selecting a menu item, pressing a toolbar which is an action usually performed by selecting a menu item, pressing a
button or any other means provided by the application to change the data toolbar button or any other means provided by the application to
or view. change the data or view.
""" """
def __init__(self, canUndo = False, name = None): def __init__(self, canUndo = False, name = None):
""" """
Constructor. wxCommand is an abstract class, so you will need to Constructor. :class:`Command` is an abstract class, so you will need to
derive a new class and call this constructor from your own constructor. derive a new class and call this constructor from your own constructor.
canUndo tells the command processor whether this command is undo-able. ``canUndo`` tells the command processor whether this command is undo-able.
You can achieve the same functionality by overriding the CanUndo member You can achieve the same functionality by overriding the CanUndo member
function (if for example the criteria for undoability is context- function (if for example the criteria for undoability is context-
dependent). dependent).
name must be supplied for the command processor to display the command ``name`` must be supplied for the command processor to display the command
name in the application's edit menu. name in the application's edit menu.
""" """
self._canUndo = canUndo self._canUndo = canUndo
@@ -2979,7 +2957,7 @@ class Command(wx.Object):
def CanUndo(self): def CanUndo(self):
""" """
Returns true if the command can be undone, false otherwise. Returns ``True`` if the command can be undone, false otherwise.
""" """
return self._canUndo return self._canUndo
@@ -2994,7 +2972,7 @@ class Command(wx.Object):
def Do(self): def Do(self):
""" """
Override this member function to execute the appropriate action when Override this member function to execute the appropriate action when
called. Return true to indicate that the action has taken place, false called. Return ``True`` to indicate that the action has taken place, false
otherwise. Returning false will indicate to the command processor that otherwise. Returning false will indicate to the command processor that
the action is not undoable and should not be added to the command the action is not undoable and should not be added to the command
history. history.
@@ -3004,10 +2982,11 @@ class Command(wx.Object):
def Undo(self): def Undo(self):
""" """
Override this member function to un-execute a previous Do. Return true Override this member function to un-execute a previous :meth:`Do`.
to indicate that the action has taken place, false otherwise. Returning Return ``True`` to indicate that the action has taken place, ``False``
false will indicate to the command processor that the action is not otherwise. Returning ``False`` will indicate to the command processor
redoable and no change should be made to the command history. that the action is not redoable and no change should be made to the
command history.
How you implement this command is totally application dependent, but How you implement this command is totally application dependent, but
typical strategies include: typical strategies include:
@@ -3028,15 +3007,15 @@ class Command(wx.Object):
class CommandProcessor(wx.Object): class CommandProcessor(wx.Object):
""" """
wxCommandProcessor is a class that maintains a history of wxCommands, with :class:`CommandProcessor` is a class that maintains a history of
undo/redo functionality built-in. Derive a new class from this if you want :class:`Commands`, with undo/redo functionality built-in. Derive a
different behaviour. new class from this if you want different behaviour.
""" """
def __init__(self, maxCommands=-1): def __init__(self, maxCommands=-1):
""" """
Constructor. maxCommands may be set to a positive integer to limit Constructor. ``maxCommands`` may be set to a positive integer to limit
the number of commands stored to it, otherwise (and by default) the the number of commands stored to it, otherwise (and by default) the
list of commands can grow arbitrarily. list of commands can grow arbitrarily.
""" """
@@ -3096,7 +3075,7 @@ class CommandProcessor(wx.Object):
def SetEditMenu(self, menu): def SetEditMenu(self, menu):
""" """
Tells the command processor to update the Undo and Redo items on this Tells the command processor to update the Undo and Redo items on this
menu as appropriate. Set this to NULL if the menu is about to be menu as appropriate. Set this to ``None`` if the menu is about to be
destroyed and command operations may still be performed, or the destroyed and command operations may still be performed, or the
command processor may try to access an invalid pointer. command processor may try to access an invalid pointer.
""" """
@@ -3163,8 +3142,8 @@ class CommandProcessor(wx.Object):
def CanUndo(self): def CanUndo(self):
""" """
Returns true if the currently-active command can be undone, false Returns ``True`` if the currently-active command can be undone,
otherwise. ``False`` otherwise.
""" """
if self._GetCurrentCommand() == None: if self._GetCurrentCommand() == None:
return False return False
@@ -3173,8 +3152,8 @@ class CommandProcessor(wx.Object):
def CanRedo(self): def CanRedo(self):
""" """
Returns true if the currently-active command can be redone, false Returns ``True`` if the currently-active command can be redone,
otherwise. ``False`` otherwise.
""" """
return self._GetCurrentRedoCommand() != None return self._GetCurrentRedoCommand() != None
@@ -3182,13 +3161,13 @@ class CommandProcessor(wx.Object):
def Submit(self, command, storeIt=True): def Submit(self, command, storeIt=True):
""" """
Submits a new command to the command processor. The command processor Submits a new command to the command processor. The command processor
calls wxCommand::Do to execute the command; if it succeeds, the calls :meth:`Command.Do` to execute the command; if it succeeds, the
command is stored in the history list, and the associated edit menu command is stored in the history list, and the associated edit menu
(if any) updated appropriately. If it fails, the command is deleted (if any) updated appropriately. If it fails, the command is deleted
immediately. Once Submit has been called, the passed command should immediately. Once Submit has been called, the passed command should
not be deleted directly by the application. not be deleted directly by the application.
storeIt indicates whether the successful command should be stored in ``storeIt`` indicates whether the successful command should be stored in
the history list. the history list.
""" """
done = command.Do() done = command.Do()