This Tkinter program displays a single label. Clicking the window's "close" decoration makes the program exit:

import Tkinter
l = Tkinter.Label(text = "See me?")
l.pack()
l.mainloop()

The last line might not even be necessary if you're using an interactive shell.


Technically, the simplest possible Tkinter program would be one without the label; instead, just:

import Tkinter
m = Tkinter.Tk()
m.mainloop()

This will just display an empty gray (or other color, depending on your system settings) window with a generic title bar!


Return to Tkinter_for_beginners.

tkinter: the_simplest_possible_Tkinter_program (last edited 2010-07-26 11:59:12 by localhost)