Our Craft

Making it better

Posts Tagged ‘TKinter’

Simple GUI with Python and TKinter

Posted by danielmeyer on October 22, 2009

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!

Posted in Technical Stuff | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.