문제

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