GTK3 drawing tutorial doesn't seem to exist?

I am learning GTK3 myself, and now I'm stuck in Gtk.DrawingArea. As with most widgets and features in GTK, there seems to be no updated documentation or tutorials on this. For reference on what I found (hope this helps some other lost googlers), lazka's automatically generated documentation was my best resource:

http://lazka.imtqy.com/pgi-docs/Gtk-3.0/classes/index.html

However, there are no methods described on the drawing area page.

http://lazka.imtqy.com/pgi-docs/Gtk-3.0/classes/DrawingArea.html

This makes me believe that I have a fundamental misunderstanding of GTK and this widget, but I can not find anything explaining how to work with it! The only textbooks I could find are them, but they are all for older versions;

3 is the best of these tutorials, but I can't get it to work on GTK3, and frankly, it's pretty advanced. Some things are also deprecated, and the replacements look rather cryptic and unclear how they work with DrawingArea: http://lazka.imtqy.com/pgi-docs/Gtk-3.0/classes/Widget.html#Gtk.Widget.set_style

There is no section on it in the official textbook, and it has not been significantly updated for a long time:

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

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

Now my question is: can someone help me figure out how to draw with Gtk.DrawingArea? Is there a gtk3 tutorial there?

My goal at the moment is to automatically draw black dots on the drawing area based on the algorithm output and display the results. I would show my code, but I have almost nothing.

+6
source share
1 answer

Basically, you 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

+7
source

Source: https://habr.com/ru/post/978291/


All Articles