I need to find out what version of GTK+ I am using. The problem is there seem to be so many different version numbers involved I am not sure which ones are most relevant.
My system is Ubuntu 12.04 and comes as standard with libgtk2.0-0, but when I installed my Python 3.2 development environment I also installed a number of other packages to bind to GTK3.
Most of the time this all 'just works', but I want to implement something that (in devhelp) is only available in Version 3.2 of GTK. Needless to say, my reason for asking is that Python cannot find the method in the API.
So, now I am wondering what (if anything) I can do about it, but first I need to find out exactly what I have got on my system.
This question seems to point in the right direction, but it is four years out of date. Does anyone have any more recent information that could help?
EDIT: Thanks to @ptomato and @Pablo for their helpful answers. My problem now is how to make sense of the different hieroglyphics that come out. The dpkg output gives (among other things) the following
bob@bobStudio:~$ dpkg -l libgtk* | grep ^i
ii libgtk-3-0 3.4.2-0ubuntu0.4 GTK+ graphical user interface library
ii libgtk-3-bin 3.4.2-0ubuntu0.4 programs for the GTK+ graphical user interface library
ii libgtk-3-common 3.4.2-0ubuntu0.4 common files for the GTK+ graphical user interface library
ii libgtk-3-dev 3.4.2-0ubuntu0.4 development files for the GTK+ library
ii libgtk-3-doc 3.4.2-0ubuntu0.4 documentation for the GTK+ graphical user interface library
[etc....]
while in the Python3 shell I get the following
>>> from gi.repository import Gtk
>>> Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
(3, 4, 2)
If I read this correctly (I am not sure I am) this means I am using GTK+ version 3.4.2, but there is some doubt because of the number on the libraries, viz, libgtk-3-0
. Also, if I am using 3.4.2, why is a method labelled as being available in 3.2 not present?
Can someone explain what the different numbers mean?
EDIT2: To be more specific, the method I am investigating is Gtk.Grid().get_child_at()
. From the DevHelp GTK+ manual,
gtk_grid_get_child_at ()
GtkWidget * gtk_grid_get_child_at (GtkGrid *grid,
gint left,
gint top);
Gets the child of grid whose area covers the grid cell whose upper left corner is at left, top.
grid : a GtkGrid
left : the left edge of the cell
top : the top edge of the cell
Returns : the child at the given position, or NULL
Since 3.2
I tried using this method in my current project and I get the following message in the stack trace;
neighbour = self.parent.grid.get_child_at(x, y)
AttributeError: 'Grid' object has no attribute 'get_child_at'
But if I am using Gtk 3.4.2, and the method was available 'since 3.2' that does not seem to make much sense. Maybe I made a mistake elsewhere?
Here is a short test program that illustrates the error (see the line marked <--------)
from gi.repository import Gtk
window = Gtk.Window()
grid = Gtk.Grid()
window.add(grid)
# the callout method
def on_button_clicked(widget):
origin = grid.get_child_at(0, 0) #<-------------
if widget == origin:
print('You clicked (0,0)')
else:
print('You clicked (1,0)')
# add a couple of widgets
button00 = Gtk.Button()
button10 = Gtk.Button()
button00.set_label('(0,0)')
button10.set_label('(1,0)')
grid.attach(button00, 0, 0, 1, 1)
grid.attach(button10, 1, 0, 1, 1)
# attach the callouts
button00.connect("clicked", on_button_clicked)
button10.connect("clicked", on_button_clicked)
# display the window
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()