How to make Toplevel() widget appear above main root window?

Question:

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?

Asked By: Tom Boy

||

Answers:

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.

try attributes

import tkinter

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

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

root.mainloop()
Answered By: andsa
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.