gtk.DrawingArea

gtk.DrawingArea — a widget for custom user interface elements.

Synopsis

class gtk.DrawingArea(gtk.Widget):
    gtk.DrawingArea()

Ancestry

+-- gobject.GObject
  +-- gtk.Object
    +-- gtk.Widget
      +-- gtk.DrawingArea

gtk.DrawingArea Properties

gtk.Object Properties

gtk.Widget Properties

gtk.DrawingArea Style Properties

gtk.Widget Style Properties

gtk.DrawingArea Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

Description

The gtk.DrawingArea widget is used for creating custom user interface elements. It's essentially a blank widget containing a gtk.gdk.Window that you can draw on. The contained gtk.gdk.Window is accessed using the gtk.Widget "window" attribute as:

  gdkwindow = drawingarea.window

Since a gtk.gdk.Window is a subclass of gtk.gdk.Drawable, all of the gtk.gdk.Drawable methods are available for drawing on the gtk.DrawingArea's gdkwindow.

After creating a drawing area, the application may want to connect to:

  • Mouse and button press signals to respond to input from the user. Use the gtk.Widget.add_events() method to enable events you wish to receive. To receive keyboard events, you will need to set the gtk.CAN_FOCUS flag on the drawing area

  • The "realize" signal to take any necessary actions when the widget is instantiated on a particular display.

  • The "configure_event" signal to take any necessary actions when the widget changes size.

  • The "expose_event" signal to handle redrawing the contents of the widget when a drawing area first comes on screen, or when it's covered by another window and then uncovered (exposed). You can also force an expose event by adding to the "damage region" of the drawing area's window using the gtk.Widget.queue_draw_area() method.

See the Drawing Area chapter in the tutorial for more information on using a gtk.DrawingArea.

Sometimes a gtk.Image is a useful alternative to a drawing area. You can put a gtk.gdk.Pixmap in the gtk.Image and draw to the gtk.gdk.Pixmap, calling the gtk.Widget.queue_draw() method on the gtk.Image when you want to refresh to the screen.

Constructor

    gtk.DrawingArea()
Returns :a new drawingarea widget

Creates a new gtk.DrawingArea widget.