title: How to open main window after successful login
body: <p>I am gettin' stared wiith python. I got a udemy course and also read this post: <a href="https://stackoverflow.com/questions/45508996/how-to-let-your-main-window-appear-after-succesful-login-in-tkinterpython-3-6">How To Let Your Main Window Appear after succesful login in Tkinter(PYTHON 3.6</a></p>
  
  <p>Still, I am unable to implement the recired event. I want to open a new (main) window of the desctop app after login. For some reason the script also opens a third window all of a sudden. I am getting really frusted working since 2 das on that stuff...</p>
  
  <p>Thanks for help :)</p>
  
  <pre><code>from tkinter import Tk, Label, Button, messagebox
  from tkinter import *
  
  class AirsoftGunRack:
  
  
      ##### Main Window #####
  
  
  
  
  
  
      ##### Login Page #####
  
  
  def __init__(self,master):
      """
  
      :type master: object
      """
  
      ##### Login Page #####
  
      self.master = master
      master.title("Login - Airsoft GunRack 3.0")
      master.geometry("450x230+450+170")
  
  
      # Creating describtions
  
      self.username = Label(master, text="Username:")
      self.username.place(relx=0.285, rely=0.298, height=20, width=55)
  
      self.password = Label(master, text="Password:")
      self.password.place(relx=0.285, rely=0.468, height=20, width=55)
  
      # Creating Buttons
  
      self.login_button = Button(master, text="Login")
      self.login_button.place(relx=0.440, rely=0.638, height=30, width=60)
      self.login_button.configure(command=self.login_user)
  
      self.exit_button = Button(master, text="Exit")  # , command=master.quit)
      self.exit_button.place(relx=0.614, rely=0.638, height=30, width=60)
      self.exit_button.configure(command=self.exit_login)
  
      # Creating entry boxes
  
      self.username_box = Entry(master)
      self.username_box.place(relx=0.440, rely=0.298, height=20, relwidth=0.35)
  
      self.password_box = Entry(master)
      self.password_box.place(relx=0.440, rely=0.468, height=20, relwidth=0.35)
      self.password_box.configure(show="*")
      self.password_box.configure(background="white")
  
      # Creating checkbox
  
      self.var = IntVar()
      self.show_password = Checkbutton(master)
      self.show_password.place(relx=0.285, rely=0.650, relheight=0.100, relwidth=0.125)
      self.show_password.configure(justify='left')
      self.show_password.configure(text='''Show''')
      self.show_password.configure(variable=self.var, command=self.cb)
  
  def cb(self, ):
  
      if self.var.get() == True:
          self.password_box.configure(show="")
      else:
          self.password_box.configure(show="*")
  
  # Giving function to login process
  
  def login_user(self):
      name = self.username_box.get()
      password = self.password_box.get()
  
      if name == "user" and password == "1234":
          self.main_win.deiconify() #Unhides the root window
          self.master.destroy()  #Removes the toplevel window
          #messagebox.showinfo("Login page", "Login successful!")
  
      else:
          messagebox.showwarning("Login failed", "Username or password incorrect!")
  
  def exit_login(self):
      msg = messagebox.askyesno("Exit login page", "Do you really want to exit?")
  
      if (msg):
          exit()
  
  
  
  
  main_win = Toplevel()
  main_win.title("Main Window")
  main_win.title("Main Window")
  main_win.geometry("800x800+450+170")
  
  root = Tk()
  gunrack = AirsoftGunRack(root)
  root.mainloop()
  #main_win.withdraw()
  main_win.mainloop()
  </code></pre>