docstrign tweaks

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-06-17 05:52:01 +00:00
parent fa003c13c7
commit fdc775af55
7 changed files with 155 additions and 104 deletions

View File

@@ -829,7 +829,6 @@ by pressing <Enter> such as the OK button on a wx.Dialog.", "");
"Set this child as temporary default", ""); "Set this child as temporary default", "");
// Navigates in the specified direction by sending a wxNavigationKeyEvent
DocDeclAStr( DocDeclAStr(
virtual bool , Navigate(int flags = wxNavigationKeyEvent::IsForward), virtual bool , Navigate(int flags = wxNavigationKeyEvent::IsForward),
"Navigate(self, int flags=NavigationKeyEvent.IsForward) -> bool", "Navigate(self, int flags=NavigationKeyEvent.IsForward) -> bool",
@@ -837,14 +836,13 @@ by pressing <Enter> such as the OK button on a wx.Dialog.", "");
`wx.NavigationKeyEvent`.", " `wx.NavigationKeyEvent`.", "
:param flags: A combination of the ``IsForward`` and ``WinChange`` :param flags: A combination of the ``IsForward`` and ``WinChange``
values in the `wx.NavigationKeyEvent` class, which values in the `wx.NavigationKeyEvent` class, which determine
determine if the navigation should be in forward or if the navigation should be in forward or reverse order, and
reverse order, and if it should be able to cross if it should be able to cross parent window boundaries, such
parent window boundaries, such as between notebook as between notebook pages or MDI child frames. Typically the
pages or MDI child frames. Typically the status of status of the Shift key (for forward or reverse) or the
the Shift key (for forward or reverse) or the Control key (for WinChange) would be used to determine how to
Control key (for WinChange) would be used to set the flags.
determine how to set the flags.
One situation in which you may wish to call this method is from a text One situation in which you may wish to call this method is from a text
control custom keypress handler to do the default navigation behaviour control custom keypress handler to do the default navigation behaviour

View File

@@ -735,21 +735,23 @@ class AnalogClockWindow(wx.PyWindow):
def SetClockStyle(self, style): def SetClockStyle(self, style):
""" """
Set the clock style, acording to the options: Set the clock style, acording to these options:
SHOW_QUARTERS_TICKS - Show marks for hours 3, 6, 9, 12 ==================== ================================
SHOW_HOURS_TICKS - Show marks for all hours SHOW_QUARTERS_TICKS Show marks for hours 3, 6, 9, 12
SHOW_MINUTES_TICKS - Show marks for minutes SHOW_HOURS_TICKS Show marks for all hours
SHOW_MINUTES_TICKS Show marks for minutes
SHOW_HOURS_HAND - Show hours hand SHOW_HOURS_HAND Show hours hand
SHOW_MINUTES_HAND - Show minutes hand SHOW_MINUTES_HAND Show minutes hand
SHOW_SECONDS_HAND - Show seconds hand SHOW_SECONDS_HAND Show seconds hand
SHOW_SHADOWS - Show hands and marks shadows SHOW_SHADOWS Show hands and marks shadows
ROTATE_TICKS - Align tick marks to watch ROTATE_TICKS Align tick marks to watch
OVERLAP_TICKS - Draw tick marks for minutes even OVERLAP_TICKS Draw tick marks for minutes even
when they match the hours marks. when they match the hours marks.
==================== ================================
""" """
self.clockStyle = style self.clockStyle = style
@@ -759,14 +761,17 @@ class AnalogClockWindow(wx.PyWindow):
""" """
Set the ticks styles, acording to the options below. Set the ticks styles, acording to the options below.
TICKS_NONE = Don't show tick marks. ================= =====================================
TICKS_SQUARE = Use squares as tick marks. TICKS_NONE Don't show tick marks.
TICKS_CIRCLE = Use circles as tick marks. TICKS_SQUARE Use squares as tick marks.
TICKS_POLY = Use a polygon as tick marks. The polygon TICKS_CIRCLE Use circles as tick marks.
must be passed using SetTickShapes, TICKS_POLY Use a polygon as tick marks. The
otherwise the default polygon will be used. polygon must be passed using
TICKS_DECIMAL = Use decimal numbers. SetTickShapes, otherwise the default
TICKS_ROMAN = Use Roman numbers. polygon will be used.
TICKS_DECIMAL Use decimal numbers.
TICKS_ROMAN Use Roman numbers.
================= =====================================
""" """
if h: if h:

View File

@@ -19,19 +19,19 @@
import wx 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 wx.LayoutConstraints.
Anchored sides maintain the distance from the edge of the Anchored sides maintain the distance from the edge of the control
control to the same edge of the parent. to the same edge of the parent. When neither side is selected,
When neither side is selected, the control keeps the same the control keeps the same relative position to both sides.
relative position to both sides.
The current position and size of the control and it's parent The current position and size of the control and it's parent is
is used when setting up the constraints. To change the size or used when setting up the constraints. To change the size or
position of an already anchored control, set the constraints to position of an already anchored control, set the constraints to
None, reposition or resize and reapply the anchors. None, reposition or resize and reapply the anchors.
Examples: Examples::
Let's anchor the right and bottom edge of a control and Let's anchor the right and bottom edge of a control and
resize it's parent. resize it's parent.
@@ -59,6 +59,7 @@ class LayoutAnchors(wx.LayoutConstraints):
| +-------*-------+ | | +-------*-------+ |
+-------------------+ +-------------------+
* = anchored edge * = anchored edge
""" """
def __init__(self, control, left=1, top=1, right=0, bottom=0): def __init__(self, control, left=1, top=1, right=0, bottom=0):
wx.LayoutConstraints.__init__(self) wx.LayoutConstraints.__init__(self)

View File

@@ -63,17 +63,17 @@ class EventManager:
""" """
Registers a listener function (or any callable object) to Registers a listener function (or any callable object) to
receive events of type event coming from the source window. receive events of type event coming from the source window.
For example: For example::
eventManager.Register(self.OnButton, EVT_BUTTON, theButton) eventManager.Register(self.OnButton, EVT_BUTTON, theButton)
Alternatively, the specific window where the event is Alternatively, the specific window where the event is
delivered, and/or the ID of the event source can be specified. delivered, and/or the ID of the event source can be specified.
For example: For example::
eventManager.Register(self.OnButton, EVT_BUTTON, win=self, id=ID_BUTTON) eventManager.Register(self.OnButton, EVT_BUTTON, win=self, id=ID_BUTTON)
or
or::
eventManager.Register(self.OnButton, EVT_BUTTON, theButton, self) eventManager.Register(self.OnButton, EVT_BUTTON, theButton, self)
""" """
# 1. Check if the 'event' is actually one of the multi- # 1. Check if the 'event' is actually one of the multi-

View File

@@ -3,42 +3,40 @@
# o Updated for 2.5 compatability. # o Updated for 2.5 compatability.
# #
"""<font weight="bold" size="16">FancyText</font> -- <font style="italic" size="16">methods for rendering XML specified text</font> """
<font family="swiss" size="12"> FancyText -- methods for rendering XML specified text
This module exports four main methods:: This module exports four main methods::
<font family="fixed" style="slant">
def GetExtent(str, dc=None, enclose=True) def GetExtent(str, dc=None, enclose=True)
def GetFullExtent(str, dc=None, enclose=True) def GetFullExtent(str, dc=None, enclose=True)
def RenderToBitmap(str, background=None, enclose=True) def RenderToBitmap(str, background=None, enclose=True)
def RenderToDC(str, dc, x, y, enclose=True) def RenderToDC(str, dc, x, y, enclose=True)
</font>
In all cases, 'str' is an XML string. Note that start and end tags In all cases, 'str' is an XML string. Note that start and end tags are
are only required if *enclose* is set to False. In this case the only required if *enclose* is set to False. In this case the text
text should be wrapped in FancyText tags. should be wrapped in FancyText tags.
In addition, the module exports one class:: In addition, the module exports one class::
<font family="fixed" style="slant">
class StaticFancyText(self, window, id, text, background, ...) class StaticFancyText(self, window, id, text, background, ...)
</font>
This class works similar to StaticText except it interprets its text This class works similar to StaticText except it interprets its text
as FancyText. as FancyText.
The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text The text can support superscripts and subscripts, text in different
in different <font size="20">sizes</font>, <font color="blue">colors</font>, <font style="italic">styles</font>, <font weight="bold">weights</font> and sizes, colors, styles, weights and families. It also supports a
<font family="script">families</font>. It also supports a limited set of symbols, limited set of symbols, currently *times*, *infinity*, *angle* as well
currently <times/>, <infinity/>, <angle/> as well as greek letters in both as greek letters in both upper case (*Alpha* *Beta*... *Omega*) and
upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>). lower case (*alpha* *beta*... *omega*).
We can use doctest/guitest to display this string in all its marked up glory.
<font family="fixed">
>>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition) >>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
>>> sft = StaticFancyText(frame, -1, __doc__, wx.Brush("light grey", wx.SOLID)) >>> sft = StaticFancyText(frame, -1, testText, wx.Brush("light grey", wx.SOLID))
>>> frame.SetClientSize(sft.GetSize()) >>> frame.SetClientSize(sft.GetSize())
>>> didit = frame.Show() >>> didit = frame.Show()
>>> from guitest import PauseTests; PauseTests() >>> from guitest import PauseTests; PauseTests()
</font></font> """
The End"""
# Copyright 2001-2003 Timothy Hochberg # Copyright 2001-2003 Timothy Hochberg
# Use as you see fit. No warantees, I cannot be held responsible, etc. # Use as you see fit. No warantees, I cannot be held responsible, etc.
@@ -403,11 +401,49 @@ renderToDC = RenderToDC
# Test Driver # Test Driver
def test(): def test():
testText =
"""<font weight="bold" size="16">FancyText</font> -- <font style="italic" size="16">methods for rendering XML specified text</font>
<font family="swiss" size="12">
This module exports four main methods::
<font family="fixed" style="slant">
def GetExtent(str, dc=None, enclose=True)
def GetFullExtent(str, dc=None, enclose=True)
def RenderToBitmap(str, background=None, enclose=True)
def RenderToDC(str, dc, x, y, enclose=True)
</font>
In all cases, 'str' is an XML string. Note that start and end tags
are only required if *enclose* is set to False. In this case the
text should be wrapped in FancyText tags.
In addition, the module exports one class::
<font family="fixed" style="slant">
class StaticFancyText(self, window, id, text, background, ...)
</font>
This class works similar to StaticText except it interprets its text
as FancyText.
The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text
in different <font size="20">sizes</font>, <font color="blue">colors</font>, <font style="italic">styles</font>, <font weight="bold">weights</font> and
<font family="script">families</font>. It also supports a limited set of symbols,
currently <times/>, <infinity/>, <angle/> as well as greek letters in both
upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>).
We can use doctest/guitest to display this string in all its marked up glory.
<font family="fixed">
>>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
>>> sft = StaticFancyText(frame, -1, __doc__, wx.Brush("light grey", wx.SOLID))
>>> frame.SetClientSize(sft.GetSize())
>>> didit = frame.Show()
>>> from guitest import PauseTests; PauseTests()
</font></font>
The End"""
app = wx.PySimpleApp() app = wx.PySimpleApp()
box = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.VERTICAL)
frame = wx.Frame(None, -1, "FancyText demo", wx.DefaultPosition) frame = wx.Frame(None, -1, "FancyText demo", wx.DefaultPosition)
frame.SetBackgroundColour("light grey") frame.SetBackgroundColour("light grey")
sft = StaticFancyText(frame, -1, __doc__) sft = StaticFancyText(frame, -1, testText)
box.Add(sft, 1, wx.EXPAND) box.Add(sft, 1, wx.EXPAND)
frame.SetSizer(box) frame.SetSizer(box)
frame.SetAutoLayout(True) frame.SetAutoLayout(True)

View File

@@ -24,42 +24,37 @@ import wx
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class FileBrowseButton(wx.Panel): class FileBrowseButton(wx.Panel):
""" A control to allow the user to type in a filename """
or browse with the standard file dialog to select file A control to allow the user to type in a filename or browse with
the standard file dialog to select file
__init__ (
parent, id, pos, size -- passed directly to wxPanel initialisation
style = wxTAB_TRAVERSAL -- passed directly to wxPanel initialisation
labelText -- Text for label to left of text field
buttonText -- Text for button which launches the file dialog
toolTip -- Help text
dialogTitle -- Title used in file dialog
startDirectory -- Default directory for file dialog startup
fileMask -- File mask (glob pattern, such as *.*) to use in file dialog
fileMode -- wxOPEN or wxSAVE, indicates type of file dialog to use
changeCallback -- callback receives all > > changes in value of control
)
GetValue() -- retrieve current value of text control
SetValue(string) -- set current value of text control
label -- pointer to internal label widget
textControl -- pointer to internal text control
browseButton -- pointer to button
""" """
def __init__ (self, parent, id= -1, def __init__ (self, parent, id= -1,
pos = wx.DefaultPosition, size = wx.DefaultSize, pos = wx.DefaultPosition,
style = wx.TAB_TRAVERSAL, size = wx.DefaultSize,
labelText= "File Entry:", style = wx.TAB_TRAVERSAL,
buttonText= "Browse", labelText= "File Entry:",
toolTip= "Type filename or click browse to choose file", buttonText= "Browse",
# following are the values for a file dialog box toolTip= "Type filename or click browse to choose file",
dialogTitle = "Choose a file", # following are the values for a file dialog box
startDirectory = ".", dialogTitle = "Choose a file",
initialValue = "", startDirectory = ".",
fileMask = "*.*", initialValue = "",
fileMode = wx.OPEN, fileMask = "*.*",
# callback for when value changes (optional) fileMode = wx.OPEN,
changeCallback= lambda x:x # callback for when value changes (optional)
changeCallback= lambda x:x
): ):
"""
:param labelText: Text for label to left of text field
:param buttonText: Text for button which launches the file dialog
:param toolTip: Help text
:param dialogTitle: Title used in file dialog
:param startDirectory: Default directory for file dialog startup
:param fileMask: File mask (glob pattern, such as *.*) to use in file dialog
:param fileMode: wx.OPEN or wx.SAVE, indicates type of file dialog to use
:param changeCallback: callback receives all changes in value of control
"""
# store variables # store variables
self.labelText = labelText self.labelText = labelText
self.buttonText = buttonText self.buttonText = buttonText
@@ -176,11 +171,13 @@ class FileBrowseButton(wx.Panel):
def GetValue (self): def GetValue (self):
""" Convenient access to text control value """ """
retrieve current value of text control
"""
return self.textControl.GetValue() return self.textControl.GetValue()
def SetValue (self, value, callBack=1): def SetValue (self, value, callBack=1):
""" Convenient setting of text control value """ """set current value of text control"""
save = self.callCallback save = self.callCallback
self.callCallback = callBack self.callCallback = callBack
self.textControl.SetValue(value) self.textControl.SetValue(value)
@@ -207,27 +204,34 @@ class FileBrowseButton(wx.Panel):
class FileBrowseButtonWithHistory( FileBrowseButton ): class FileBrowseButtonWithHistory( FileBrowseButton ):
""" with following additions: """
with following additions:
__init__(..., history=None) __init__(..., history=None)
history -- optional list of paths for initial history drop-down history -- optional list of paths for initial history drop-down
(must be passed by name, not a positional argument) (must be passed by name, not a positional argument)
If history is callable it will must return a list used If history is callable it will must return a list used
for the history drop-down for the history drop-down
changeCallback -- as for FileBrowseButton, but with a work-around changeCallback -- as for FileBrowseButton, but with a work-around
for win32 systems which don't appear to create wx.EVT_COMBOBOX for win32 systems which don't appear to create wx.EVT_COMBOBOX
events properly. There is a (slight) chance that this work-around events properly. There is a (slight) chance that this work-around
will cause some systems to create two events for each Combobox will cause some systems to create two events for each Combobox
selection. If you discover this condition, please report it! selection. If you discover this condition, please report it!
As for a FileBrowseButton.__init__ otherwise. As for a FileBrowseButton.__init__ otherwise.
GetHistoryControl() GetHistoryControl()
Return reference to the control which implements interfaces Return reference to the control which implements interfaces
required for manipulating the history list. See GetHistoryControl required for manipulating the history list. See GetHistoryControl
documentation for description of what that interface is. documentation for description of what that interface is.
GetHistory() GetHistory()
Return current history list Return current history list
SetHistory( value=(), selectionIndex = None ) SetHistory( value=(), selectionIndex = None )
Set current history list, if selectionIndex is not None, select that index Set current history list, if selectionIndex is not None, select that index
""" """
def __init__( self, *arguments, **namedarguments): def __init__( self, *arguments, **namedarguments):
self.history = namedarguments.get( "history" ) self.history = namedarguments.get( "history" )
@@ -257,12 +261,15 @@ class FileBrowseButtonWithHistory( FileBrowseButton ):
def GetHistoryControl( self ): def GetHistoryControl( self ):
"""Return a pointer to the control which provides (at least) """
the following methods for manipulating the history list.: Return a pointer to the control which provides (at least)
the following methods for manipulating the history list:
Append( item ) -- add item Append( item ) -- add item
Clear() -- clear all items Clear() -- clear all items
Delete( index ) -- 0-based index to delete from list Delete( index ) -- 0-based index to delete from list
SetSelection( index ) -- 0-based index to select in list SetSelection( index ) -- 0-based index to select in list
Semantics of the methods follow those for the wxComboBox control Semantics of the methods follow those for the wxComboBox control
""" """
return self.textControl return self.textControl

View File

@@ -942,18 +942,22 @@ class ScaledText(DrawObject, TextObjectMixin, XYObjectMixin):
Family: Family:
Font family, a generic way of referring to fonts without Font family, a generic way of referring to fonts without
specifying actual facename. One of: specifying actual facename. One of::
wx.DEFAULT: Chooses a default font. wx.DEFAULT: Chooses a default font.
wx.DECORATI: A decorative font. wx.DECORATI: A decorative font.
wx.ROMAN: A formal, serif font. wx.ROMAN: A formal, serif font.
wx.SCRIPT: A handwriting font. wx.SCRIPT: A handwriting font.
wx.SWISS: A sans-serif font. wx.SWISS: A sans-serif font.
wx.MODERN: A fixed pitch font. wx.MODERN: A fixed pitch font.
NOTE: these are only as good as the wxWindows defaults, which aren't so good. NOTE: these are only as good as the wxWindows defaults, which aren't so good.
Style: Style:
One of wx.NORMAL, wx.SLANT and wx.ITALIC. One of wx.NORMAL, wx.SLANT and wx.ITALIC.
Weight: Weight:
One of wx.NORMAL, wx.LIGHT and wx.BOLD. One of wx.NORMAL, wx.LIGHT and wx.BOLD.
Underline: Underline:
The value can be True or False. At present this may have an an The value can be True or False. At present this may have an an
effect on Windows only. effect on Windows only.
@@ -1952,8 +1956,8 @@ def _makeFloatCanvasAddMethods(): ## lrk's code for doing this in module __init_
addshapemethod = getaddshapemethod() addshapemethod = getaddshapemethod()
methodname = "Add" + classname methodname = "Add" + classname
setattr(FloatCanvas, methodname, addshapemethod) setattr(FloatCanvas, methodname, addshapemethod)
docstring = "Creates %s and adds its reference to the canvas.\n" % classname docstring = " Creates %s and adds its reference to the canvas.\n" % classname
docstring += "Argument protocol same as %s class" % classname docstring += " Argument protocol same as %s class" % classname
if klass.__doc__: if klass.__doc__:
docstring += ", whose docstring is:\n%s" % klass.__doc__ docstring += ", whose docstring is:\n%s" % klass.__doc__
FloatCanvas.__dict__[methodname].__doc__ = docstring FloatCanvas.__dict__[methodname].__doc__ = docstring