tkinter - tk window remains

Eric Brunel eric.brunel at pragmadev.com
Fri Nov 15 04:20:12 EST 2002


Dubois, Jeff wrote:
>   I am using Tkinter to bring up a ScrolledText window.
>   However, when the user closes the window by clicking on the X button in
> the upper right of the ScrolledText window the "tk" window remains.  Based
> on documentation I have read I have tried using the .withdraw() method in
> hopes the tk window would disappear.  However the tk window still remains.
> The code I am using is:
> 
>                 rootWin = Tk()
>                 rootWin.withdraw()
>                 st = ScrolledText(master=rootWin)
>                 st.pack(side=TOP, expand=1, fill=BOTH)
>                 st.insert(END, "\n\n\n\n       THIS IS MAIN WINDOW!\n")
>                 rootWin.mainloop()
> 
>   I am using python2.1 on an Windows NT operating system.

Where did you get your ScrolledText class? Even the one delivered with 
Tkinter (which is utterly broken and that you definetely shouldn't use) 
doesn't show this behaviour. Apparently, the one you're using is quite 
broken if it opens a new window. The st.pack stuff should create the 
ScrolledText widget in the "tk" window, so you shouldn't have to do a 
rootWin.withdraw().

My advice(s) would be:

1/ Create the ScrolledText with ScrolledText(rootWin) instead of 
ScrolledText(master=rootWin). The "master=" stuff is not needed and can 
lead to problems like yours

2/ Use a better ScrolledText class, like the one in Pmw (see 
http://pmw.sourceforge.net). And I'm quite sure you'll want all the other 
classes in Pmw too...!

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list