message box in Tkinter

Eric Brunel eric.brunel at pragmadev.nospam.com
Tue Aug 17 14:12:01 CEST 2010


In article 
<61cbd1cb-bd6d-49aa-818f-d28c460980ea at x18g2000pro.googlegroups.com>,
 Jah_Alarm <jah.alarm at gmail.com> wrote:

> 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 -



More information about the Python-list mailing list