pythongtkpygobject

Python and Gtk - which GTK version is being used?


from gi.repository import Gtk

#print Gtk.GTK_MAJOR_VERSION

win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()

That is my code, how can I know which version of Gtk is being used.

Thank you!


Solution

  • You can use the following functions to get the version information:

    import gi
    gi.require_version("Gtk", "3.0")
    from gi.repository import Gtk
    
    maj_v = Gtk.get_major_version() # 3
    min_v = Gtk.get_minor_version() # 24
    mic_v = Gtk.get_micro_version() # 33
    
    print(f"Gtk version: {maj_v}.{min_v}.{mic_v}") # Gtk version: 3.24.33