1.2 Drawing

Python Xt supports drawing operations, usable e.g. in Motif DrawingArea widgets and on off-screen Pixmaps. In general the X man pages should be consulted for the precise semantics.

An off-screen Pixmap can be created using the widget method CreatePixmap.

In order to draw in a widget or on a Pixmap, a Graphics Context object instance must be created. This can be done using the widget methods CreateGC() and GetGC(), or the Pixmap method CreateGC().

Once a Graphics Context object is instantiated, the Xlib drawing functions can be used. These drawing functions are methods of the Graphics Context object.

For example, in order to draw a rectangle in a window, the following code could be used.

    values = {'line_style': X.LineOnOffDash}
    gc = w.GetGC(values)
    gc.DrawRectangle(x, y, width, height)