Processing
 

Python script using Glade code produces glib error about old version of GTK

25/09/2014 00:41#1

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

I am trying to create my first Glade GUI using Python as the back-end. I created the GUI in Glade and saved the file as a .glade. I then created my Python code and saved it in the same directory as the glade file. Upon running the Python file in the terminal, I receive the following message:

    Traceback (most recent call last):       File "glade6.py", line 56, in <module>         main = Buglump()       File "glade6.py", line 20, in __init__         self.builder.add_from_file("glade6.glade")     glib.GError: glade6.glade: required gtk+ version 3.10, current version is 2.24 

OS: Ubuntu 14.04.1 LTS 64-bit

And the Python file that was run: Code acquired from 'http://gnipsel.com/glade/index.html'

    #!/usr/bin/env python     import sys      try:        import gtk       import gtk.glade     except:       print('GTK not available')       sys.exit(1)     try:       import pygtk       pygtk.require('2.0')     except:       pass      class Buglump:        def __init__(self):         self.builder = gtk.Builder()         self.builder.add_from_file("glade6.glade")         self.builder.connect_signals(self)          # the liststore         self.liststore = gtk.ListStore(int,str)         self.liststore.append([0,"Select an Item:"])         self.liststore.append([1,"Row 1"])         self.liststore.append([2,"Row 2"])         self.liststore.append([3,"Row 3"])         self.liststore.append([4,"Row 4"])         self.liststore.append([5,"Row 5"])          # the combobox         self.combobox = self.builder.get_object("combobox1")         self.combobox.set_model(self.liststore)         self.cell = gtk.CellRendererText()         self.combobox.pack_start(self.cell, True)         self.combobox.add_attribute(self.cell, 'text', 1)         self.combobox.set_active(0)          self.window = self.builder.get_object("window1")         self.window1.show()        def on_combobox1_changed(self, widget, data=None):         self.index = widget.get_active()         self.model = widget.get_model()         self.item = self.model[self.index][1]         print "ComboBox Active Text is", self.item         print "ComboBox Active Index is", self.index         self.builder.get_object("label1").set_text(self.item)        def on_window1_destroy(self, object, data=None):         print "quit with cancel"         gtk.main_quit()      if __name__ == "__main__":       main = Buglump()       gtk.main() 
11/11/2014 14:31Top#2

Christian

Member

Joined at: 10 months ago

Post: 125

Thank: 0

Thanked: 0

import gtk actually imports gtk+2.x. If you need to use gtk+3, assuming you already have it installed, you need to write:

From gi.repository import Gtk (with capital letter G) 

Remove these lines:

import gtk  import gtk.glade 

and remember to change all instances of gtk inside your code to Gtk. Example: change gtk.main_quit() to Gtk.main_quit()

18/07/2016 19:10Top#3

Jay Marm

Member

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

Was also getting the required gtk+ version 3x, current version is 2x error

The problem is that the newest version of Glade doesn't run with the default GTK version in Ubuntu.

I finally got it working by installing the older Glade V3.8.5 Note: I'm working on Xenial/16.04.

By installing the older version you can create Glade GUIs that run under GTK2.

Steps:

  • remove the newer Glade (i.e. apt-get remove Glade) version
  • download the V3.8.5 version of Glade (which is the last version to support GTK2) from: http://ftp.gnome.org/pub/GNOME/sources/glade/3.8/
  • follow the install instructions (./configure, make, makeinstall)

I also needed to install these missing components (YMMV):

libgtk2.0-dev, intltool, libxml2-devel

It installed. But... when I ran it.. it died:

glade-3: error while loading shared libraries: libgladeui-1.so.11: cannot open shared object file: No such file or directory

So finally I installed: libgladeui*

Rebooted... voila. Glade runs... the GUI I created works in Python2 (import gtk).

Similar articles

Non-interactive method for dpkg-reconfigure tzdata

5 years ago - Reply: 3 - Views: 140

monit is not able to read mongod.lock

2 years ago - Reply: 3 - Views: 138

Ubuntu: hadoop command not found

2 years ago - Reply: 4 - Views: 244

C# Mono Console.ReadLine quitting

4 years ago - Reply: 1 - Views: 87

linking jsoncpp on Ubuntu

2 years ago - Reply: 1 - Views: 5

Build artifacts over ssh jenkins - PHP

2 years ago - Reply: 1 - Views: 37

Can't load Metasploit after installation

2 years ago - Reply: 5 - Views: 212

Selenium FirefoxDriver in Headless get error

2 years ago - Reply: 1 - Views: 96

Unable to start MongoDB. ERROR: addr already in use

2 years ago - Reply: 2 - Views: 118

ZSH Agnoster Theme showing machine name

2 years ago - Reply: 4 - Views: 248

Unable to start firefox browser with jenkins user

2 years ago - Reply: 2 - Views: 110

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re