How to interact with main window while message box is visible?

I have a problem. I am using Tkinter for a GUI and I have a message box appear. (like a warning or info) The problem is, that you can't interact with the main window once the message box appears, which I have to. How can I interact with both windows at the same time?

This is my code I currently use:

import tkinter as tk
from tkinter import messagebox as mb
def answer():
    mb.showerror("Answer", "Sorry, no answer available")

def callback():
    if mb.askyesno('Verify', 'Really quit?'):
        mb.showwarning('Yes', 'Not yet implemented')
    else:
        mb.showinfo('No', 'Quit has been cancelled')

tk.Button(text='Quit', command=callback).pack(fill=tk.X)
tk.Button(text='Answer', command=answer).pack(fill=tk.X)
tk.mainloop()

1 answer

  • answered 2021-10-24 15:30 Bryan Oakley

    The messagebox is designed explicitly to have the behavior you've seen. If you want to display a popup window with a message and still be able to interact with the main window, you'll need to create your own window for the message with Toplevel.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum