The following "Hello World" program in python is more Gtk like than most programs, as it inherits and extends the gtk.Window.

   1 import gtk
   2 
   3 class HelloWorld(gtk.Window):
   4     def button_clicked(self, data):
   5         print "Hello World!"
   6         
   7     def __init__(self):
   8         gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
   9 
  10         self.connect("destroy", gtk.main_quit)
  11         
  12         button = gtk.Button("Press me")
  13         button.connect("clicked", self.button_clicked)
  14         button.show()
  15         self.add(button)
  16 
  17 HelloWorld().show()
  18 gtk.main()

Attic/DovsPythonHelloWorld (last edited 2013-11-22 23:15:58 by WilliamJonMcCann)