Вопрос

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?

Это было полезно?

Решение

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().

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top