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 , , , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects