Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tkinter messagebox always appears behind main pygame window

I am trying to make my messagebox appear in front of my pygame window, but it keeps appearing behind it. Here's my code:

from tkinter import messagebox

# pygame loop here
messagebox.showinfo("Title", "Message here")

Do I need to do add some lines of code to bring it to the front? Any help would be appreciated.

like image 842
o.o Avatar asked Dec 06 '25 05:12

o.o


1 Answers

I got it to work. I had to add root.withdraw() as well.

import tkinter as tk
from tkinter import messagebox

root = tk.Tk()
root.withdraw()

# pygame loop here
messagebox.showinfo("Title", "Message here")
root.lift()

Not sure why hiding the root tkinter window makes it work...

like image 87
o.o Avatar answered Dec 08 '25 06:12

o.o



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!