0

Hi. I'm new user in ubuntu and I like very much the glade interface designer.
I designed my first app and tryed to run it from python with this script:

#!/usr/bin/env python

import sys
import pygtk
import gtk
import gtk.glade

class MainWindow:
	""" This is the main window """
	def __init__(self):
		# Set the glade file
		self.gladefile = "GUI.glade"
		self.wTree = gtk.glade.XML(self.gladefile)
		
		# Get the main window
		self.window = self.wTree.get_widget("MainWindow")
		if (self.window):
			self.window.connect("destroy", gtk.main_quit)

if __name__ == "__main__":
	MainWindow = MainWindow()
	gtk.main()

When I run it from terminal there is no ouptput, but the frame never appears.
What is wrong with it?

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by wolih
0

I think there needs to be a self.window.show() in __init__ similar to the example below.

# very basic GTK/Python program showing just a window
# you have to install GTK runtime, PyCairo, PyGobject and PyGTK for this to work

import gtk

class Base(object):
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.show()

    def main(self):
        gtk.main()


if __name__ == "__main__":
    base = Base()
    base.main()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.