Skip to content Skip to sidebar Skip to footer

Python3: How Can I Find Out What Version Of Gtk+ I Am Using?

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

Solution 1:

Type the following at your Python prompt or do the equivalent in a script:

>>>from gi.repository import Gtk>>>Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
(3, 4, 3)

This number is the actual version number of GTK that you are using. The libgtk-3-0 package indicates that that package is for the 3.0 series, which every subsequent version with a major version number of 3 is compatible with. If they renamed the package for 3.2, etc., then you wouldn't be able to upgrade it and all your other packages would break.

As for Gtk.Grid.get_child_at(), it's not available in my Python setup with Gtk 3.4.2 either. This is odd, since the Python API is automatically generated from the C API. If you are facing a problem like this, then the first thing to do is double-check that there's not a different error in your program:

>>>from gi.repository import Gtk>>>grid = Gtk.Grid()>>>'get_child_at'indir(grid)
False

So there really is no method. Sometimes methods are marked as (skip) in the documentation comments, meaning they are C-only and shouldn't show up in bindings in other languages; so check that too. The GTK source code is online here; search for get_child_at and you'll see there is no (skip) annotation. So that's not the problem either.

The next thing to do is to check the PyGObject source code for an override. Sometimes certain methods are superseded by something that's more Pythonic; for example, grid[0, 0] would be much more Pythonic than grid.get_child_at(0, 0) and it would be awesome if the PyGObject team had thought of that.

>>> grid[0, 0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Grid' object has no attribute '__getitem__'

No such luck. So look at PyGObject's GTK overrides here and search for get_child_at, Grid, etc. No mention.

So the only possibility remaining that I can think of, is a bug. Go to http://bugzilla.gnome.org and report the lack of this method in the Python bindings. If you're feeling ambitious, why not suggest the grid[0, 0] notation to them as well?

Solution 2:

Open your preferred shell and do with the gtk name that is currently installed

 rpm -q gtk2
 rpm -ql --info gtk2-2.8.20-1 |less

or look closer at this page. http://forums.fedoraforum.org/showthread.php?t=119358

This should work for debian I think

 dpkg -l | grep libgtk

more info ca be found here http://manpages.ubuntu.com/manpages/lucid/man1/dpkg.1.html

Post a Comment for "Python3: How Can I Find Out What Version Of Gtk+ I Am Using?"