message box in Tkinter

J

Jah_Alarm

I need to display a message box at the click of a button. I od the
following:

from Tkinter import *

def msg1():
messagebox.showinfo(message='Have a good day')


Button(mainframe,text="About",command=msg1()).grid(column=360,row=36,sticky=W)

I get the error msg 'global name 'messagebox' is not defined'

When I try importing messagebox from Tkinter i get an error message
that this module doesn't exist.

thanks
 
E

Eric Brunel

Jah_Alarm said:
I need to display a message box at the click of a button. I od the
following:

from Tkinter import *

def msg1():
messagebox.showinfo(message='Have a good day')


Button(mainframe,text="About",command=msg1()).grid(column=360,row=36,sticky=W)

I get the error msg 'global name 'messagebox' is not defined'

When I try importing messagebox from Tkinter i get an error message
that this module doesn't exist.

thanks

Where did you find any reference to something called messagebox? The
actual module name is tkMessageBox and it should be imported separately:

import tkMessageBox
tkMessageBox.showinfo(message='Have a good day')

Should work that way.
HTH
- Eric -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top