Reputation: 8696
Question
How can I hide the two Tkinter root windows that are popping up in my program? I have tried to use root.widthdraw()
. Here is a link to my Pastebin.
Background
I am trying to create a really basic email client to learn more about Tkinter and SMTP. I have decided that my program will first create a Toplevel window where the user will enter their credentials, and if the Server can authenticate them, then the program opens the email send dialogue. Annoyingly, I have not been able to hide the 2 other root windows which open when the program starts up. I have attempted to use root.widthdraw()
to avoid this issue.
Relevant Code
#-----Authen is a toplevel class-------------
passcheck = Authen()
root = Tk()
root.mainloop()
root.widthdraw()
Upvotes: 2
Views: 957
Reputation: 385900
You should create your root window before creating any other windows. Otherwise you get exactly what you observe: Tkinter will automatically create a root window the first time you create some other widget, and the you are creating a second one.
Upvotes: 2
Reputation: 12747
I'm running Python2.7, with the default tkinter
package, and my root
object doesn't have a withdraw()
method. Besides that, you can also just run mainloop
off the toplevel
called passcheck
and it'll save you a window.
class Authen(Frame):
def __init__(self, master):
Frame.__init__(self, master)
then:
root = Tk()
passcheck = Authen(root)
root.mainloop()
edit: Here's a solution, instead of Authen
being a TopLevel
, have it be a Frame
instead, and pass root
as it's master. http://pastebin.com/TtnvU0er
Upvotes: 1