Tk from IDLE: How to 'Hello World'?

Kirby Urner urner at alumni.princeton.edu
Fri Sep 29 02:17:44 EDT 2000


Kirby Urner <urner at alumni.princeton.edu> wrote:

>
>Writing it interactively in IDLE, one would go:
>
> >>> from Tkinter import *
> >>> def test():
>	root = Tk()
>        w = Label(root, text="Hello, world!")
>        w.pack()
>        root.mainloop()
>
> >>> test()
>
>Which gets you the Tk window saying Hello World, as expected.  
>
>But then if you hit the close box, do you get back to a working 
>IDLE prompt?  I don't.  I'm left in limbo, with a prompt I can't
>go back to.

Emails told me it's the same in other versions of Python,
and in Linux.

HOWEVER, one guru said I should go root.mainloop(1) and it
the close box would return me to a working IDLE prompt.
Lo and behold, that works!

There must be a secret source of knowledge about Tk that
I don't have -- even though I bouth John Grayson's tome.

Kirby





More information about the Python-list mailing list