7
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!

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
David Gomes
  • 5,644
  • 16
  • 60
  • 103

2 Answers2

14

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

Gtk.get_major_version()
Gtk.get_minor_version()
Gtk.get_micro_version()
Szilárd Pfeiffer
  • 1,636
  • 1
  • 12
  • 6
  • 1
    Links to the docs for those wondering: https://developer.gnome.org/pygtk/stable/gtk-constants.html; https://developer.gnome.org/gtk3/stable/gtk3-Feature-Test-Macros.html – user3467349 Jun 07 '15 at 18:29
0

For check in .gir files:

grep -rin 'get_[a-zA-Z]*_version' /usr/share/gir-1.0/Gtk-3.0.gir

Example output:

grep -rin 'get_[a-zA-Z]*_version' /usr/share/gir-1.0/Gtk-3.0.gir
108409:    <function name="get_major_version"
108410:              c:identifier="gtk_get_major_version"
108424:    <function name="get_micro_version"
108425:              c:identifier="gtk_get_micro_version"
108439:    <function name="get_minor_version"
108440:              c:identifier="gtk_get_minor_version"
shakaran
  • 10,612
  • 2
  • 29
  • 46