tkinter showinfo python 3

mihota picture mihota · Jun 25, 2014 · Viewed 48k times · Source

I am trying to show an info window by using

tkinter.messagebox.showinfo("info", "message")

However, I am getting error while using from tkinter import *

The problem is solve if I also have import tkinter.messagebox

So I am confused. Isn't from tkinter import * is supposed to import everything inside tkinter?

Answer

josti picture josti · Jan 10, 2016
from tkinter import *

from tkinter import messagebox

root = Tk()

root.title("test")
root.geometry("300x300")

app = Frame(root)
app.grid()
button1 = Button(app, text = " exit " , width=2, command=exit)
button1.grid(padx=110, pady=80)

def dialog():
    var = messagebox.showinfo("test" , "hoi, dit is een test als je dit leest is het gelukt")
button2 = Button(app, text = " uitleg " , width=4, command=dialog)
button2.grid()


root.mainloop(3)

you just import messagebox from tkinter and you do messagebox.(for example)showinfo("test" , "blablablabla")