GTK3 Drawing area tutorial does not seem to exist?

5.3k views Asked by At

I've been learning GTK3 on my own and I'm now stuck on Gtk.DrawingArea. As with most widgets and functions in GTK, there seems to be a lack of updated documentation and tutorials on this. For reference as to what I've found(hopefully this will help some other lost googlers), lazka's auto-generated documentation has been my best resource:

http://lazka.github.io/pgi-docs/Gtk-3.0/classes/index.html

However the drawing area page has no methods described.

http://lazka.github.io/pgi-docs/Gtk-3.0/classes/DrawingArea.html

This leads me to believe that I have a fundamental misunderstanding of GTK and this widget, but I can't find anything explaining how to work with it! The only tutorials I could find were these, but they are all for older versions;

3 is best of these tutorials, but I can't seem to get it to work in GTK3, and honestly its pretty advanced. Several things are also deprecated and the replacements seem to be pretty cryptic and are unclear how they work with DrawingArea: http://lazka.github.io/pgi-docs/Gtk-3.0/classes/Widget.html#Gtk.Widget.set_style

The official tutorial doesn't have a section on it, and hasn't been significantly updated in a long time:

http://python-gtk-3-tutorial.readthedocs.org/en/latest/objects.html

https://github.com/sebp/PyGObject-Tutorial

My question now is whether someone could help me understand how to draw with Gtk.DrawingArea? Is there a gtk3 tutorial out there?

My goal at the moment is to automatically draw black points on a drawing area based on an algorithm's output, and display the results. I would show my code but I barely have anything.

1

There are 1 answers

3
lazka On BEST ANSWER

You basically connect to the ::draw signal and draw in the handler using pycairo. And use queue_draw/queue_draw_area() if you want to redraw.

See http://zetcode.com/gfx/pycairo/basicdrawing/ for examples