0

I'm making a login system, and I called mainloop in the first window that will be opened upon starting the program. This window is the window which asks whether the user would like to login or register. Obviously, this means I can't close this window at all, which is impractical and I was hoping to be able to use mainloop instead in the main window that will open once the user has logged in, which will be a window where they will be able to play my game. Will this cause any issues in the program, or will everything run as usual?

vlthi
  • 1
  • `.mainloop()` returns only when there are no more `tkinter` windows left. So as long as you have 1 `tkinter` window open, `.mainloop()` shouldn't exit. You need to give us some of your code for a more specific answer. – TheLizzard May 22 '21 at 18:02

1 Answers1

0

call the mainloop for every window you make for example if you make a window as root=Tk() then after writing all the code for the window write root.mainloop() in the end

  • this shouldn't really be done, this is and can be interpreted incorrectly, and a very bad advice for new programmers and in general. There should be only one `mainloop()` in the whole code (for beginners especially), also windows can be made using `Toplevel` for whom You don't need to call `mainloop()`. Obviously it is possible to manage this too, but it is way easier to just keep one `mainloop()`. and it is not strictly necessary to put code only before `mainloop()` it is just that the code after that will be executed when the window is closed, which comes in handy sometimes – Matiiss May 22 '21 at 19:07
  • Thanks man , for telling me about it :) . – Raunak Singh May 24 '21 at 18:00