Question

I know that you need to subclass Gtk.DrawingArea in PyGObject in order to create a custom widget. You then connect the draw signal to a callback that looks like this:

def on_draw(drawing_area, cr):
    # do something with cr
    return False

To ask for a redraw, you would call my_widget.queue_draw().

Now, I know that you may ask to redraw a specific region of the surface using my_widget.queue_draw_area(). When your on_draw callback gets called after this, how do you know the region to draw?

Was it helpful?

Solution

the draw virtual function is called with the invalidated area already part of the clip imposed on the Cairo context.

if you want to know the extents of the clipped region you can use the python wrapper for gdk_cairo_get_clip_rectangle().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top