GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Show Source
  • index
  • modules
  • next
  • previous
  • Home
  • Gallery
  • API Docs
  • Overview Documents
  • Device Contexts

This view

  • Original page
  • New address

GeezerVison is showing docs.wxpython.org — Device Contexts — wxPython 4.3.2 Docs

phoenix_title Device Contexts¶

A wx.DC is a device context onto which graphics and text can be drawn. The device context is intended to represent a number of output devices in a generic way, with the same API being used throughout.

Some device contexts are created temporarily in order to draw on a window. This is true of wx.ScreenDC, wx.ClientDC, wx.PaintDC, and wx.WindowDC. The following describes the differences between these device contexts and when you should use them.

  • wx.ScreenDC. Use this to paint on the screen, as opposed to an individual window.

  • wx.ClientDC. Use this to paint on the client area of window (the part without borders and other decorations), but do not use it from within an wx.PaintEvent.

  • wx.PaintDC. Use this to paint on the client area of a window, but only from within a wx.PaintEvent.

  • wx.WindowDC. Use this to paint on the whole area of a window, including decorations. This may not be available on non-Windows platforms.

To use a client, paint or window device context, create an object on the stack with the window as argument, for example:

def OnMyCmd(self, event):
    dc = wx.ClientDC(window)
    DrawMyPicture(dc)

Try to write code so it is parameterised by wx.DC - if you do this, the same piece of code may write to a number of different devices, by passing a different device context. This doesn’t work for everything (for example not all device contexts support bitmap drawing) but will work most of the time.

© Copyright 2012-2026, The wxPython Team. Created using Sphinx 9.1.0 and the python-docs-theme.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.