2

I have made a Toplevel widget but when it pops up it always appears below my root window. Is there an easy way I can make it come to the top most level when it pops up?

Tom Boy
  • 599
  • 2
  • 8
  • 14

2 Answers2

4

you can use the .lift() method on a Toplevel widget:

import tkinter

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

top = tkinter.Toplevel(root)
top.title("top")
top.lift(root)
root.mainloop()

according to this documentation you should be able to just use top.lift() to raise above all other windows but it didn't seem to work for me.

Edit: calling top.lift() without arguments does work when called during the mainloop, although since this question was specifically when starting the program that isn't very useful.

Tadhg McDonald-Jensen
  • 20,699
  • 5
  • 35
  • 59
1

try attributes

import tkinter

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

top = tkinter.Toplevel(root)
top.attributes('-topmost', 'true')
top.title("top")

root.mainloop()
andsa
  • 221
  • 2
  • 5