The main Device Context is called "wxDC."

You can't instantiate wxDC directly; It's just there for interface specification, and documentation purposes.

Instead, you instantiate a subclass of wxDC.


Something important to know: If your device context involves drawing to the screen, it matters whether you are in the middle of handling an EVT_PAINT event, or not. (EVT_PAINT events are sent by the system when the gui is being redrawn: e.g. window dragging)

You need one DC while handling an EVT_PAINT handler, and another when you're not.

Within EVT_PAINT, you use a wx.PaintDC object. In fact, you have to. See PaintEvent.

Outside, you use a wx.WindowDC.

If you want to draw on a buffer first, then you choose between wx.BufferedPaintDC (within an EVT_PAINT), or, wx.BufferedDC (outside EVT_PAINT.)

Buffered Device Contexts

Some device contexts are buffered, and have this curious property: They draw to the screen when the device context is deleted.

That is, when the device context goes out of scope, then it is suddenly copied to the screen, before dying.

DeviceContext (last edited 2013-07-07 01:04:16 by 198-84-183-34)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.