Tkinter: Make it go away!

Rick Pasotto rickp at telocity.com
Wed Apr 25 19:12:27 EDT 2001


On Wed, 25 Apr 2001 14:41:43 -0700 in comp.lang.python, Phlip wrote:
> To Phyn:
> 
>   from Tkinter import *
>   root = Tk()
>   lab1 = Label(root, text='simple 1')
>   lab1.pack()  
> 
>   # ???
> 
>   lab2 = Label(root, text='simple 2')
>   lab2.pack()
>   root.mainloop()
> 
> When I run that, I get a window with two labels in it.
> 
> On the line with ???, what can I write to get only one label? How do I 
> croak an object prematurely?

Is there some reason not to just change the text in the label that's
already there?

lab1.config(text='simple 2')

If you insist on putting up with the possible flickering as the window
resizes:

lab1.destroy()

-- 
"The principle which protects personal writings & any other
productions of the intellect or of the emotions, is the right to
privacy & the law has no new principle to formulate when it extends
this protection to the personal appearance, sayings, acts, & to
personal relations, domestic or otherwise."
		-- Samuel D. Warren & Louis D. Brandeis
		   1890-12-15 "The Right to Privacy"
		   _Harvard Law Review_ volume 4 #5 pg 193
		   Rick Pasotto email: rickp at telocity.com



More information about the Python-list mailing list