GUI
MyPaint uses GObject-Introspection (“GI”) to access certain third-party libraries. This is a mechanism that allows library code written in a compiled language to be used by scripting languages. It’s normally not possible to do this directly. The Python library for using other libs through GI is called PyGObject or PyGI.
Discovering PyGI
It’s easy to spot Python code which uses it: it will always have imports looking like the following near the top.
from gi.repository import Gdk
from gi.repository import Gtk
GObject-Introspection rewrites the names of class definitions, methods, and functions so that they make the most sense in the target language. For example, if you’re constructing a GTK button in C, you’d do
GtkWidget *button = gtk_button_new(...);
gtk_button_set_label(button, "Click me");
but the equivalent Python code is
button = Gtk.Button()
button.set_label("Click me")
The documentation for GTK and GDK is not readily available through GI. You have to consult the C API documentation for the library instead. To make matching up the C function/class names and their Python equivalents, you can use pygi-grep, a tool for searching Python-GObject namespaces.
$ pygi-grep -vi -r 3.0 Gtk tree.*row
from gi.repository import Gtk
Gtk.TreeModelRow
Gtk.TreeModelRowIter
Gtk.TreeRowReference
Gtk.tree_get_row_drag_data
Gtk.tree_row_reference_deleted
Gtk.tree_row_reference_inserted
Gtk.tree_set_row_drag_data
Learning GTK+ and GDK
The C interfaces for GTK+ and GDK are well documented:
You may also wish to install Devhelp for offline browsing.