Python and GObject Introspection

Uploaded on


More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Python and GObject-Introspection Yuren Ju <>
  • 2. About me●● Hacking Thursday● KaLUG● Twitter: @yurenju
  • 3. GObject
  • 4. D-BUS notifyGlade GTK VTE
  • 5. GNOME platform
  • 6. Binding Librarybased on GObject
  • 7. Use codegen to generate GTK C Wrapper for Python gtk.c number of lines: 128,469
  • 8. If GTK+ add APIs in new version,python-gtk also need to upgrade for new APIs.
  • 9. Implement in Python,Also need to re-implement in Ruby, Perl, Java, Javscript again.
  • 10. GObject-Introspection
  • 11. Originalpython-gobject metadata GTK+ GTK+
  • 12. GObject-Introspection python-gobject parser metadata GTK+ GTK+
  • 13. Same metadata format python-gobject parsermetadata metadata metadataGTK+GTK+ gstreamer GTK+ ... GTK+
  • 14. Parser + metadata = GObject-Introspection
  • 15. tut-triangle tut.triangle+ get_color()+ set_color()+ get_centroid()+ get_centroidu()
  • 16. MetadataComments in Source code g-ir-scanner Gir XML file g-ir-compiler Typelib binary file
  • 17. Comments in Source code
  • 18. Gir XML file
  • 19. Metadata Comments in Source code g-ir-scanner Gir XML file g-ir-compilerlibgirepository Typelib binary file
  • 20. python-gobjectPyGTK 2.24.0 has been released. This is a stable release supporting the GTK+2.24 API. New users wishing to develop Python applications using GTK+ arerecommended to use the GObject-Introspection features available inPyGObject. Existing authors of PyGTK applications are also recommended toport their applications to PyGObject to take advantage of new featuresappearing in GTK-3 and beyond.
  • 21. gtk.c number of lines:128,469
  • 22. How to use GI?from gi.repository import Gtk;
  • 23. PEP-0302: New Import Hooks Append finder to sys.meta_path,Use finder.find_module() dynamic to find module.
  • 24. Load module● find_module()● load_module() ● Create DynamicModule ● Module._load() – Create self._introspection_module ● IntrospectionModule => repository.requre to load typelib
  • 25. Objectfrom gi.repository import Gtk - Widget - ContainerInitial all items in Gtk - WindowGet info from ...etc.repository.find_by_name()If item is a object instance, Use a MetaClass“GobjectMeta” to create a class wrapperFinally, you have a Python Class to create Object!
  • 26. Method – relative easy object.method() Call info.invoke() g_function_info_invoke
  • 27. Summary● GI Migrate metadata from language-binding to library● python-gobject let you use GTK, GObject, Gstreamer, VTE, Dbus,...etc.
  • 28. 一人成佛,雞犬升天