pythonware.com products ::: library ::: search ::: daily Python-URL!
   

Hello, Tkinter

Back   Next   

 Chapter 2. Hello, Tkinter

Table of Contents
Running the Example
Details

But enough talk. Time to look at some code instead.

As you know, every serious tutorial should start with a "hello world"-type example. In this overview, we'll show you not only one such example, but two.

First, let's look at a pretty minimal version:

Example 2-1. Our First Tkinter Program

# File: hello1.py

from Tkinter import *

root = Tk()

w = Label(root, text="Hello, world!")
w.pack()

root.mainloop()

 Running the Example

To run the program, run the script as usual:

$ python hello1.py

The following window appears.

Figure 2-1. Running the program

To stop the program, just close the window.

Back   Next