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

2 Answers 2

16

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
Sign up to request clarification or add additional context in comments.

1 Comment

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.