0

my python code is:

gtk = CDLL('/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so')
builder = gtk.gtk_builder_new()
print gtk.gtk_builder_add_from_file(builder, './mainui.glade', None)

I tested the c code, it works. But with python ctype, the result of gtk_builder_add_from_file is always 0, e.g there is an error. I'm very confused..

1 Answers1

1

Why don't you use the introspection feature? There is a reason it exists.

from gi.repository import Gtk as gtk

class Foo (object):

    def __init__(self):
        self.builder = gtk.Builder()
        self.builder.add_from_file("someui.glade")
        self.builder.connect_signals(self)

    def run(self, *args):
        self.builder.get_object("mainwindow").show()
        gtk.main()

    def quit(self, *args):
        gtk.main_quit()


Foo().run()

if that is not an option, pass a GError ** instead of none to get some more information regarding the issue (might be in your *.glade file or missing permissions)

drahnr
  • 6,782
  • 5
  • 48
  • 75