Windows and Buttons in Python – Ten Lines of PyGTK

It’s easy to write grahical user interface with python.
Write twindow to a text file, then run it.

$ nano twindow.py
$ python twindow

Do you see a window? Does it print some text to command line when you click the button? Well done, you made your first graphical user interface program with Python.

twindow.py

import gtk
def thello(widget):
        print "Button was clicked. TeroKarvinen.com"
w=gtk.Window()
w.connect("destroy", gtk.main_quit)
b=gtk.Button("Click me")
b.connect("clicked", thello)
w.add(b)
w.show_all()
gtk.main()

Posted in Uncategorized | Tagged , , , , , , | Comments Off on Windows and Buttons in Python – Ten Lines of PyGTK

Comments are closed.