putting glade interface in python

后端 未结 5 534
别跟我提以往
别跟我提以往 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 03:10

    This works perfectly.

    #!/usr/bin/python
    import pygtk
    pygtk.require("2.0")
    import gtk
    import gtk.glade
    class SubinsWindow:
     def __init__(self):
      self.gladefile = "game.glade"
      self.glade = gtk.Builder()
      self.glade.add_from_file(self.gladefile)
      self.glade.connect_signals(self)
      self.win=self.glade.get_object("window1") # Window Name in GLADE
      self.win.show_all()
    
    if __name__ == "__main__":
     a = SubinsWindow()
     gtk.main()
    

提交回复
热议问题