All windows that are visible on the screen issue some drawing commands to a Device Context (often referred to as a DC) to tell the system what kind of pixel information to display on the screen. Some control's classes, such as
wx.Control
, wx.Window
, and wx.Panel
allow for user-defined control of what is drawn on the screen through the use of wx.EVT_PAINT
. This recipe provides an introduction to screen drawing by creating a simple little slideshow widget that will load a PNG or JPG file from a directory, and then draw that image on the screen along with some label text below it, to show which image is out of the set.
Here we will look at our ImageCanvas
widget. Starting with its constructor we Bind
to
EVT_PAINT
so that we can get call backs from the framework when a part of our window has been marked as needing to be redrawn:
import os import wx class ImageCanvas(wx.PyPanel): def __init__(self, parent): super(SlideShowPanel, self).__init__(parent...