phoenix_title wx.adv.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.


class_hierarchy Class Hierarchy

Inheritance diagram for class PseudoDC:

method_summary Methods Summary

__init__

Constructs a new Pseudo device context for recording and

Clear

Clears the device context using the current background brush.

ClearId

Removes all operations associated with id so the object can be redrawn.

CrossHair

Displays a cross hair using the current pen. This is a

DrawArc

Draws an arc of a circle, centred on the center point

DrawBitmap

Draw a bitmap on the device context at the specified

DrawCheckMark

Draws a check mark inside the given rectangle

DrawCircle

Draws a circle with the given center point and radius.

DrawEllipse

Draws an ellipse contained in the specified rectangle. The current pen

DrawEllipticArc

Draws an arc of an ellipse, with the given rectangle

DrawIcon

Draw an icon on the display at the given position.

DrawIdToDC

Draw recorded operations tagged with id to dc.

DrawLabel

Draw text within the specified rectangle, abiding by the

DrawLine

Draws a line from the first point to the second.

DrawLines

Draws lines using a sequence of wx.Point objects, adding the

DrawPoint

Draws a point using the current pen.

DrawPolygon

Draws a filled polygon using a sequence of wx.Point objects, adding

DrawRectangle

Draws a rectangle with the given top left corner, and with

DrawRotatedText

Draws the text rotated by angle degrees, if supported by the platform.

DrawRoundedRectangle

Draws a rectangle with the given top left corner, and with

DrawSpline

Draws a spline between all given control points, (a list of wx.Point

DrawText

Draws a text string at the specified point, using the

DrawToDC

Draws the recorded operations to dc.

DrawToDCClipped

Draws the recorded operations to dc,

DrawToDCClippedRgn

Draws the recorded operations to dc,

FindObjects

Returns a list of all the id’s that draw a pixel with

FindObjectsByBBox

Returns a list of all the id’s whose bounding boxes include (x,y).

FloodFill

Flood fills the device context starting from the given point,

GetIdBounds

Returns the bounding rectangle previously set with SetIdBounds.

GetIdGreyedOut

Get whether the set of objects with tag id are drawn greyed out or not.

GetLen

Returns the number of operations in the recorded list.

RemoveAll

Removes all objects and operations from the recorded list.

RemoveId

Remove the object node (and all operations) associated with an id.

SetBackground

Sets the current background brush for the DC.

SetBackgroundMode

The mode parameter may be one of wx.SOLID and

SetBrush

Sets the current brush for the DC.

SetFont

Sets the current font for the DC. It must be a valid font, in

SetId

Sets the id to be associated with subsequent operations.

SetIdBounds

Set the bounding rect of a given object.

SetIdGreyedOut

Set whether the set of objects with tag id are drawn greyed out or not.

SetLogicalFunction

Sets the current logical function for the device context. This

SetPen

Sets the current pen for the DC.

SetTextBackground

Sets the current text background colour for the DC.

SetTextForeground

Sets the current text foreground colour for the DC.

TranslateId

Translate the position of the operations of tag id by (dx, dy).


property_summary Properties Summary

Len

See GetLen


api Class API

class 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.


Methods

__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.

Parameters:

id (int) –



CrossHair(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:
  • x (int) –

  • y (int) –



CrossHair (self, pt)

Parameters:

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.

Parameters:
  • x1 (int) –

  • y1 (int) –

  • x2 (int) –

  • y2 (int) –

  • xc (int) –

  • yc (int) –



DrawBitmap(self, *args, **kw)

overload Overloaded Implementations:



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).

Parameters:
  • bmp (wx.Bitmap) –

  • x (int) –

  • y (int) –

  • useMask (bool) –



DrawBitmap (self, bmp, pt, useMask=False)

Parameters:





DrawCheckMark(self, *args, **kw)

overload Overloaded Implementations:



DrawCheckMark (self, x, y, width, height)

Draws a check mark inside the given rectangle

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –



DrawCheckMark (self, rect)

Parameters:

rect (wx.Rect) –





DrawCircle(self, *args, **kw)

overload Overloaded Implementations:



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

DrawEllipse

Parameters:
  • x (int) –

  • y (int) –

  • radius (int) –



DrawCircle (self, pt, radius)

Parameters:





DrawEllipse(self, *args, **kw)

overload Overloaded Implementations:



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

DrawCircle

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –



DrawEllipse (self, rect)

Parameters:

rect (wx.Rect) –



DrawEllipse (self, pt, sz)

Parameters:





DrawEllipticArc(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:
  • x (int) –

  • y (int) –

  • w (int) –

  • h (int) –

  • start (float) –

  • end (float) –



DrawEllipticArc (self, pt, sz, start, end)

Parameters:





DrawIcon(self, *args, **kw)

overload Overloaded Implementations:



DrawIcon (self, icon, x, y)

Draw an icon on the display at the given position.

Parameters:
  • icon (wx.Icon) –

  • x (int) –

  • y (int) –



DrawIcon (self, icon, pt)

Parameters:





DrawIdToDC(self, id, dc)

Draw recorded operations tagged with id to dc.

Parameters:
  • id (int) –

  • dc (wx.DC) –



DrawLabel(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:
  • 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.

Parameters:
  • text (string) –

  • image (wx.Bitmap) –

  • rect (wx.Rect) –

  • alignment (int) –

  • indexAccel (int) –





DrawLine(self, *args, **kw)

overload Overloaded Implementations:



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).

Parameters:
  • x1 (int) –

  • y1 (int) –

  • x2 (int) –

  • y2 (int) –



DrawLine (self, pt1, pt2)

Parameters:





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.

Parameters:
  • points (PointList) –

  • xoffset (int) –

  • yoffset (int) –



DrawPoint(self, *args, **kw)

overload Overloaded Implementations:



DrawPoint (self, x, y)

Draws a point using the current pen.

Parameters:
  • x (int) –

  • y (int) –



DrawPoint (self, pt)

Parameters:

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) or wx.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.

Parameters:
  • points (PointList) –

  • xoffset (int) –

  • yoffset (int) –

  • fillStyle (PolygonFillMode) –



DrawRectangle(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –



DrawRectangle (self, rect)

Parameters:

rect (wx.Rect) –



DrawRectangle (self, pt, sz)

Parameters:





DrawRotatedText(self, *args, **kw)

overload Overloaded Implementations:



DrawRotatedText (self, text, x, y, angle)

Draws the text rotated by angle degrees, if supported by the platform.

Parameters:
  • text (string) –

  • x (int) –

  • y (int) –

  • angle (float) –



DrawRotatedText (self, text, pt, angle)

Parameters:
  • text (string) –

  • pt (wx.Point) –

  • angle (float) –





DrawRoundedRectangle(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –

  • radius (float) –



DrawRoundedRectangle (self, rect, radius)

Parameters:
  • rect (wx.Rect) –

  • radius (float) –



DrawRoundedRectangle (self, pt, sz, radius)

Parameters:





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’.

Parameters:

points (PointList) –



DrawText(self, *args, **kw)

overload Overloaded Implementations:



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

DrawRotatedText

Parameters:
  • text (string) –

  • x (int) –

  • y (int) –



DrawText (self, text, pt)

Parameters:





DrawToDC(self, dc)

Draws the recorded operations to dc.

Parameters:

dc (wx.DC) –



DrawToDCClipped(self, dc, rect)

Draws the recorded operations to dc, unless the operation is known to be outside of rect.

Parameters:


DrawToDCClippedRgn(self, dc, region)

Draws the recorded operations to dc, unless the operation is known to be outside the given region.

Parameters:


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.

Parameters:
  • x (int) –

  • y (int) –

  • radius (int) –

  • bg (wx.Colour) –

Return type:

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.

Parameters:
  • x (int) –

  • y (int) –

Return type:

PyObject



FloodFill(self, *args, **kw)

overload Overloaded Implementations:



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.

Parameters:



FloodFill (self, pt, col, style=FLOOD_SURFACE)

Parameters:





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).

Parameters:

id (int) –

Return type:

Rect



GetIdGreyedOut(self, id)

Get whether the set of objects with tag id are drawn greyed out or not.

Parameters:

id (int) –

Return type:

bool



GetLen(self)

Returns the number of operations in the recorded list.

Return type:

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.

Parameters:

id (int) –



SetBackground(self, brush)

Sets the current background brush for the DC.

Parameters:

brush (wx.Brush) –



SetBackgroundMode(self, mode)

The mode parameter may be one of wx.SOLID and wx.TRANSPARENT. This setting determines whether text will be drawn with a background colour or not.

Parameters:

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

wx.Brush

Parameters:

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

wx.Font

Parameters:

font (wx.Font) –



SetId(self, id)

Sets the id to be associated with subsequent operations.

Parameters:

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.

Parameters:


SetIdGreyedOut(self, id, greyout)

Set whether the set of objects with tag id are drawn greyed out or not.

Parameters:
  • 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.

Parameters:

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

wx.Pen

Parameters:

pen (wx.Pen) –



SetTextBackground(self, colour)

Sets the current text background colour for the DC.

Parameters:

colour (Colour) –



SetTextForeground(self, colour)

Sets the current text foreground colour for the DC.

Parameters:

colour (wx.Colour) –



TranslateId(self, id, dx, dy)

Translate the position of the operations of tag id by (dx, dy).

Parameters:
  • id (int) –

  • dx (int) –

  • dy (int) –


Properties

Len

See GetLen