from tkinter import * from tkinter import messagebox root = Tk() def msgbox(): messagebox.showinfo(title="A Message", message="Hello World!") b1 = Button(root, text="msgbox", command=msgbox) b1.pack(pady=20,padx=20) root.mainloop()