Simple GUI with Python and TKinter

It would be nice to have a way to build quick-n-dirty GUIs so I can GUI-enable tools when that makes sense… but I’ve always just had a mental block about “going to that length”.

Yesterday though, I was flipping through Python in a Nutshell and I saw a GUI example there (p. 329) that was so simple I typed it in and tried it out :

import sys, Tkinter
Tkinter.Label(text="Welcome!").pack()
Tkinter.Button(text="Exit", command=sys.exit).pack()
Tkinter.mainloop()

That yields a simple little dialog:

hellotk-1

…that can be resized:

hellotk-2

I need to try some more of this!

Advertisements

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s