pythonpython-3.xtkintercustomtkintertoplevel

Top Level Widget Not appearing above the Main widget in customtkinter/tkinter


I am using a top level widget in customtkinter to show an error, but the top level widget goes below the main widget so the user doesn't end up noticing the error. How can I make the top level widget a priority and make it appear in front of the main widget.

here's an example of what's happening-

import customtkinter
    
app=customtkinter.CTk()

if: #something happens
  #do normal function
else: #error happens
  err=customtkinter.CTkToplevel()
  err.geometry("350x100")
  err.title("Error")     
  err.resizable(False,False)
  err.state("normal")
  err.anchor("center")

app.mainloop()

this new top level window is appearing below the main window.


Solution

  • "Make the toplevel a transient window of the root window using .wm_transient(), then the toplevel will always be in front of the root window."

    Worked for me thanks!

    used toplevel.wm_transient(app)

    thanks