0

I am Programing a small Program in Tkinter and wanted to have two windows open. Then i wanted to bring one Window in front. Program Code:

from tkinter import *

root = Tk()
root.title("ROOT")

new = Tk()
new.title("NEW")
new.lift()

root.mainloop()
new.lift()

new.mainloop()

new.lift()

What did i did wrong with new.lift? New dosn´t come to front :( Does someone know how to bring a Window in front and give the Window focus?

1 Answers1

0

The main problem is that you can't have two instances of Tk at the same time, and you can't have two mainloops running at the same time.

To create more than one window use Topolevel,

new = Toplevel(root)

Do not call mainloop a second time, it's unnecessary. Also, don't put any executable code after the call to mainloop because mainloop won't return until the main window has been destroyed.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685