A PseudoDC is an object that can be used much like real
wx.DC
, however it provides some additional features for object recording and manipulation beyond what awx.DC
can provide.All commands issued to the
PseudoDC
are stored in a list. You can then play these commands back to a real DC object as often as needed, using theDrawToDC
method or one of the similar methods. Commands in the command list can be tagged by anID
. You can use thisID
to clear the operations associated with a singleID
, redraw the objects associated with thatID
, grey them, adjust their position, etc.
Constructs a new Pseudo device context for recording and |
|
Clears the device context using the current background brush. |
|
Removes all operations associated with id so the object can be redrawn. |
|
Displays a cross hair using the current pen. This is a |
|
Draws an arc of a circle, centred on the center point |
|
Draw a bitmap on the device context at the specified |
|
Draws a check mark inside the given rectangle |
|
Draws a circle with the given center point and radius. |
|
Draws an ellipse contained in the specified rectangle. The current pen |
|
Draws an arc of an ellipse, with the given rectangle |
|
Draw an icon on the display at the given position. |
|
Draw recorded operations tagged with id to dc. |
|
Draw text within the specified rectangle, abiding by the |
|
Draws a line from the first point to the second. |
|
Draws lines using a sequence of |
|
Draws a point using the current pen. |
|
Draws a filled polygon using a sequence of |
|
Draws a rectangle with the given top left corner, and with |
|
Draws the text rotated by angle degrees, if supported by the platform. |
|
Draws a rectangle with the given top left corner, and with |
|
Draws a spline between all given control points, (a list of |
|
Draws a text string at the specified point, using the |
|
Draws the recorded operations to dc. |
|
Draws the recorded operations to dc, |
|
Draws the recorded operations to dc, |
|
Returns a list of all the id’s that draw a pixel with |
|
Returns a list of all the id’s whose bounding boxes include (x,y). |
|
Flood fills the device context starting from the given point, |
|
Returns the bounding rectangle previously set with SetIdBounds. |
|
Get whether the set of objects with tag id are drawn greyed out or not. |
|
Returns the number of operations in the recorded list. |
|
Removes all objects and operations from the recorded list. |
|
Remove the object node (and all operations) associated with an id. |
|
Sets the current background brush for the DC. |
|
The mode parameter may be one of |
|
Sets the current brush for the DC. |
|
Sets the current font for the DC. It must be a valid font, in |
|
Sets the id to be associated with subsequent operations. |
|
Set the bounding rect of a given object. |
|
Set whether the set of objects with tag id are drawn greyed out or not. |
|
Sets the current logical function for the device context. This |
|
Sets the current pen for the DC. |
|
Sets the current text background colour for the DC. |
|
Sets the current text foreground colour for the DC. |
|
Translate the position of the operations of tag id by (dx, dy). |
See |
wx.adv.
PseudoDC
(Object)¶Possible constructors:
PseudoDC()
A PseudoDC is an object that can be used much like real
wx.DC
, however it provides some additional features for
object recording and manipulation beyond what a wx.DC
can
provide.
All commands issued to the PseudoDC
are stored in a list. You
can then play these commands back to a real DC object as often as
needed, using the DrawToDC
method or one of the similar
methods. Commands in the command list can be tagged by an ID
. You
can use this ID
to clear the operations associated with a single
ID
, redraw the objects associated with that ID
, grey them, adjust
their position, etc.
__init__
(self)¶Constructs a new Pseudo device context for recording and replaying DC operations.
Clear
(self)¶Clears the device context using the current background brush.
ClearId
(self, id)¶Removes all operations associated with id so the object can be redrawn.
id (int) –
CrossHair
(self, *args, **kw)¶CrossHair (self, x, y)
Displays a cross hair using the current pen. This is a vertical and horizontal line the height and width of the window, centred on the given point.
x (int) –
y (int) –
CrossHair (self, pt)
pt (wx.Point) –
DrawArc
(self, x1, y1, x2, y2, xc, yc)¶Draws an arc of a circle, centred on the center point (xc, yc), from the first point to the second. The current pen is used for the outline and the current brush for filling the shape.
The arc is drawn in an anticlockwise direction from the start point to the end point.
x1 (int) –
y1 (int) –
x2 (int) –
y2 (int) –
xc (int) –
yc (int) –
DrawBitmap
(self, *args, **kw)¶DrawBitmap (self, bmp, x, y, useMask=False)
Draw a bitmap on the device context at the specified point. If useMask is
True
and the bitmap has a transparency mask, (or alpha channel on the platforms that support it) then the bitmap will be drawn transparently.When drawing a mono-bitmap, the current text foreground colour will be used to draw the foreground of the bitmap (all bits set to 1), and the current text background colour to draw the background (all bits set to 0).
See also
bmp (wx.Bitmap) –
x (int) –
y (int) –
useMask (bool) –
DrawBitmap (self, bmp, pt, useMask=False)
DrawCheckMark
(self, *args, **kw)¶DrawCheckMark (self, x, y, width, height)
Draws a check mark inside the given rectangle
x (int) –
y (int) –
width (int) –
height (int) –
DrawCheckMark (self, rect)
rect (wx.Rect) –
DrawCircle
(self, *args, **kw)¶DrawCircle (self, x, y, radius)
Draws a circle with the given center point and radius. The current pen is used for the outline and the current brush for filling the shape.
See also
x (int) –
y (int) –
radius (int) –
DrawCircle (self, pt, radius)
pt (wx.Point) –
radius (int) –
DrawEllipse
(self, *args, **kw)¶DrawEllipse (self, x, y, width, height)
Draws an ellipse contained in the specified rectangle. The current pen is used for the outline and the current brush for filling the shape.”, “
See also
x (int) –
y (int) –
width (int) –
height (int) –
DrawEllipse (self, rect)
rect (wx.Rect) –
DrawEllipse (self, pt, sz)
DrawEllipticArc
(self, *args, **kw)¶DrawEllipticArc (self, x, y, w, h, start, end)
Draws an arc of an ellipse, with the given rectangle defining the bounds of the ellipse. The current pen is used for drawing the arc and the current brush is used for drawing the pie.
The start and end parameters specify the start and end of the arc relative to the three-o’clock position from the center of the rectangle. Angles are specified in degrees (360 is a complete circle). Positive values mean counter-clockwise motion. If start is equal to end, a complete ellipse will be drawn.
x (int) –
y (int) –
w (int) –
h (int) –
start (float) –
end (float) –
DrawEllipticArc (self, pt, sz, start, end)
DrawIcon
(self, *args, **kw)¶DrawIcon (self, icon, x, y)
Draw an icon on the display at the given position.
icon (wx.Icon) –
x (int) –
y (int) –
DrawIcon (self, icon, pt)
DrawIdToDC
(self, id, dc)¶Draw recorded operations tagged with id to dc.
id (int) –
dc (wx.DC) –
DrawLabel
(self, *args, **kw)¶DrawLabel (self, text, rect, alignment=ALIGN_LEFT|ALIGN_TOP, indexAccel=-1)
Draw text within the specified rectangle, abiding by the alignment flags. Will additionally emphasize the character at indexAccel if it is not -1.
text (string) –
rect (wx.Rect) –
alignment (int) –
indexAccel (int) –
DrawLabel (self, text, image, rect, alignment=ALIGN_LEFT|ALIGN_TOP, indexAccel=-1)
Draw text and an image (which may be
wx.NullBitmap
to skip drawing it) within the specified rectangle, abiding by the alignment flags. Will additionally emphasize the character at indexAccel if it is not -1.
DrawLine
(self, *args, **kw)¶DrawLine (self, x1, y1, x2, y2)
Draws a line from the first point to the second. The current pen is used for drawing the line. Note that the second point is not part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits).
x1 (int) –
y1 (int) –
x2 (int) –
y2 (int) –
DrawLine (self, pt1, pt2)
DrawLines
(self, points, xoffset=0, yoffset=0)¶Draws lines using a sequence of
wx.Point
objects, adding the optional offset coordinate. The current pen is used for drawing the lines.
points (PointList) –
xoffset (int) –
yoffset (int) –
DrawPoint
(self, *args, **kw)¶DrawPoint (self, x, y)
Draws a point using the current pen.
x (int) –
y (int) –
DrawPoint (self, pt)
pt (wx.Point) –
DrawPolygon
(self, points, xoffset=0, yoffset=0, fillStyle=ODDEVEN_RULE)¶Draws a filled polygon using a sequence of
wx.Point
objects, adding the optional offset coordinate. The last argument specifies the fill rule:wx.ODDEVEN_RULE
(the default) orwx.WINDING_RULE
.The current pen is used for drawing the outline, and the current brush for filling the shape. Using a transparent brush suppresses filling. Note that wxWidgets automatically closes the first and last points.
points (PointList) –
xoffset (int) –
yoffset (int) –
fillStyle (PolygonFillMode) –
DrawRectangle
(self, *args, **kw)¶DrawRectangle (self, x, y, width, height)
Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape.
x (int) –
y (int) –
width (int) –
height (int) –
DrawRectangle (self, rect)
rect (wx.Rect) –
DrawRectangle (self, pt, sz)
DrawRotatedText
(self, *args, **kw)¶DrawRotatedText (self, text, x, y, angle)
Draws the text rotated by angle degrees, if supported by the platform.
text (string) –
x (int) –
y (int) –
angle (float) –
DrawRotatedText (self, text, pt, angle)
text (string) –
pt (wx.Point) –
angle (float) –
DrawRoundedRectangle
(self, *args, **kw)¶DrawRoundedRectangle (self, x, y, width, height, radius)
Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape.
x (int) –
y (int) –
width (int) –
height (int) –
radius (float) –
DrawRoundedRectangle (self, rect, radius)
rect (wx.Rect) –
radius (float) –
DrawRoundedRectangle (self, pt, sz, radius)
DrawSpline
(self, points)¶Draws a spline between all given control points, (a list of
wx.Point
objects) using the current pen. The spline is drawn using a series of lines, using an algorithm taken from the X drawing program ‘XFIG
’.
points (PointList) –
DrawText
(self, *args, **kw)¶DrawText (self, text, x, y)
Draws a text string at the specified point, using the current text font, and the current text foreground and background colours.
The coordinates refer to the top-left corner of the rectangle bounding the string. See
wx.DC.GetTextExtent
for how to get the dimensions of a text string, which can be used to position the text more precisely, (you will need to use a real DC with GetTextExtent as wx.PseudoDC does not implement it.)
NOTE
: under wxGTK the current logical function is used by this function but it is ignored by wxMSW. Thus, you should avoid using logical functions with this function in portable programs.”, “See also
text (string) –
x (int) –
y (int) –
DrawText (self, text, pt)
text (string) –
pt (wx.Point) –
DrawToDCClipped
(self, dc, rect)¶Draws the recorded operations to dc, unless the operation is known to be outside of rect.
DrawToDCClippedRgn
(self, dc, region)¶Draws the recorded operations to dc, unless the operation is known to be outside the given region.
FindObjects
(self, x, y, radius=1, bg=WHITE)¶Returns a list of all the id’s that draw a pixel with color not equal to bg within radius of (x,y). Returns an empty list if nothing is found. The list is in reverse drawing order so list[0] is the top id.
x (int) –
y (int) –
radius (int) –
bg (wx.Colour) –
PyObject
FindObjectsByBBox
(self, x, y)¶Returns a list of all the id’s whose bounding boxes include (x,y). Returns an empty list if nothing is found. The list is in reverse drawing order so list[0] is the top id.
x (int) –
y (int) –
PyObject
FloodFill
(self, *args, **kw)¶FloodFill (self, x, y, col, style=FLOOD_SURFACE)
Flood fills the device context starting from the given point, using the current brush colour, and using a style:
wx.FLOOD_SURFACE
: the flooding occurs until a colour other than the given colour is encountered.
wx.FLOOD_BORDER
: the area to be flooded is bounded by the given colour.
x (int) –
y (int) –
col (wx.Colour) –
style (FloodFillStyle) –
FloodFill (self, pt, col, style=FLOOD_SURFACE)
pt (wx.Point) –
col (wx.Colour) –
style (FloodFillStyle) –
GetIdBounds
(self, id)¶Returns the bounding rectangle previously set with
SetIdBounds
. If no bounds have been set, it returns wx.Rect(0,0,0,0).
id (int) –
Rect
GetIdGreyedOut
(self, id)¶Get whether the set of objects with tag id are drawn greyed out or not.
id (int) –
bool
GetLen
(self)¶Returns the number of operations in the recorded list.
int
RemoveAll
(self)¶Removes all objects and operations from the recorded list.
RemoveId
(self, id)¶Remove the object node (and all operations) associated with an id.
id (int) –
SetBackground
(self, brush)¶Sets the current background brush for the DC.
brush (wx.Brush) –
SetBackgroundMode
(self, mode)¶The mode parameter may be one of
wx.SOLID
andwx.TRANSPARENT
. This setting determines whether text will be drawn with a background colour or not.
mode (int) –
SetBrush
(self, brush)¶Sets the current brush for the DC.
If the argument is
wx.NullBrush
, the current brush is selected out of the device context, and the original brush restored, allowing the current brush to be destroyed safely.See also
brush (wx.Brush) –
SetFont
(self, font)¶Sets the current font for the DC. It must be a valid font, in particular you should not pass
wx.NullFont
to this method.See also
font (wx.Font) –
SetId
(self, id)¶Sets the id to be associated with subsequent operations.
id (int) –
SetIdBounds
(self, id, rect)¶Set the bounding rect of a given object. This will create an object node if one doesn’t exist.
id (int) –
rect (wx.Rect) –
SetIdGreyedOut
(self, id, greyout)¶Set whether the set of objects with tag id are drawn greyed out or not.
id (int) –
greyout (bool) –
SetLogicalFunction
(self, function)¶Sets the current logical function for the device context. This determines how a source pixel (from a pen or brush colour, combines with a destination pixel in the current device context.
The possible values and their meaning in terms of source and destination pixel values are defined in the wx.RasterOperationMode enumeration.
The default is wx.``wx.COPY``, which simply draws with the current colour. The others combine the current colour and the background using a logical operation. wx.``wx.INVERT`` is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour.
function (RasterOperationMode) –
SetPen
(self, pen)¶Sets the current pen for the DC.
If the argument is
wx.NullPen
, the current pen is selected out of the device context, and the original pen restored.See also
pen (wx.Pen) –
SetTextBackground
(self, colour)¶Sets the current text background colour for the DC.
colour (Colour
) –
SetTextForeground
(self, colour)¶Sets the current text foreground colour for the DC.
colour (wx.Colour) –
TranslateId
(self, id, dx, dy)¶Translate the position of the operations of tag id by (dx, dy).
id (int) –
dx (int) –
dy (int) –