putting glade interface in python

后端 未结 5 533
别跟我提以往
别跟我提以往 2021-02-06 02:30

I\'ve made a gui in glade that I want to put in a python program. I was adapting the instructions from a tutorial I found online to load in my glade file (http://www.pygtk.org/a

5条回答
  •  无人及你
    2021-02-06 02:51

    If you are using GTK+3 in python, see builder.

    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk
    
    class Handler:
        def onDestroy(self, *args):
            Gtk.main_quit()
    
        def onButtonPressed(self, button):
            print("Hello World!")
    
    builder = Gtk.Builder()
    builder.add_from_file("builder_example.glade")
    builder.connect_signals(Handler())
    
    window = builder.get_object("window1")
    window.show_all()
    
    Gtk.main()
    

提交回复
热议问题