TkMessageBox - No Module TkMessageBox - No Module tkinter tkinter

TkMessageBox - No Module


In Python3.x things have changed a little bit:

   >>> import tkinter   >>> import tkinter.messagebox   >>>

I mean what we call tkMessageBox in Python2.x becomes tkinter.messagebox in Python3.x


If you don't want to have to change the code for Python 2 vs Python 3, you can use import as:

try:    from tkinter import messageboxexcept ImportError:    # Python 2    import tkMessageBox as messagebox

Then using messagebox as follows will work in either version:

messagebox.showerror("Error", "Message.")


In Python 2.x, to import, you'd say import tkMessageBox. But in Python 3.x, it's been renamed to import tkinter.messagebox.

Hope it helped :))