DrawingArea
Superclasses: Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
- Constructors:
DrawingArea(**properties)
new() -> Gtk.Widget
Constructors
Methods
- class DrawingArea
-
- set_content_height(height: int) None
Sets the desired height of the contents of the drawing area.
Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual height passed to your draw function is larger than the height set here. You can use
set_valign
to avoid that.If the height is set to 0 (the default), the drawing area may disappear.
- Parameters:
height – the height of contents
- set_content_width(width: int) None
Sets the desired width of the contents of the drawing area.
Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual width passed to your draw function is larger than the width set here. You can use
set_halign
to avoid that.If the width is set to 0 (the default), the drawing area may disappear.
- Parameters:
width – the width of contents
- set_draw_func(draw_func: Callable[[...], None] | None = None, *user_data: Any) None
Setting a draw function is the main thing you want to do when using a drawing area.
The draw function is called whenever GTK needs to draw the contents of the drawing area to the screen.
The draw function will be called during the drawing stage of GTK. In the drawing stage it is not allowed to change properties of any GTK widgets or call any functions that would cause any properties to be changed. You should restrict yourself exclusively to drawing your contents in the draw function.
If what you are drawing does change, call
queue_draw
on the drawing area. This will cause a redraw and will calldraw_func
again.- Parameters:
draw_func – callback that lets you draw the drawing area’s contents
user_data – user data passed to
draw_func
Properties
Signals
- class DrawingArea.signals
- resize(width: int, height: int) None
Emitted once when the widget is realized, and then each time the widget is changed while realized.
This is useful in order to keep state up to date with the widget size, like for instance a backing surface.
- Parameters:
width – the width of the viewport
height – the height of the viewport
Virtual Methods
Fields
- class DrawingArea
- widget