Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get tkinter messagebox to appear in front of toplevel

Tags:

python

tkinter

I'm writing a program with Python 3 and tkinter in which toplevels initially appear centered in the root window. If a toplevel isn't moved out of the way, it covers up any messagebox that may arise to display an error message. The messagebox appears in front of the root window, but behind the toplevel. Simple example from the command line to show what happens:

>>> from tkinter import *
>>> from tkinter import messagebox
>>> root = Tk()
>>> texto = Toplevel(root) # (Manually put toplevel in front of root)
>>> messagebox.showinfo(message='Does this work?')

Is there a way to get the messagebox to appear in front of the toplevel?

like image 408
McClamrock Avatar asked Oct 20 '25 11:10

McClamrock


1 Answers

Instead of master I tried by using: "parent" as this one Messagebox with top level as Master and it worked for me!

messagebox.showinfo("title", "message",parent=texto)
like image 93
Cecilia Barboza Avatar answered Oct 23 '25 00:10

Cecilia Barboza