message box in Tkinter

Discussion in 'Python' started by Jah_Alarm, Aug 17, 2010.

  1. Jah_Alarm

    Jah_Alarm Guest

    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
     
    Jah_Alarm, Aug 17, 2010
    #1
    1. Advertising

  2. Jah_Alarm

    Matt Saxton Guest

    On Tue, 17 Aug 2010 04:02:23 -0700 (PDT)
    Jah_Alarm <> wrote:

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


    I believe what you want is Tkinter.Message


    --
    Matt Saxton <>
     
    Matt Saxton, Aug 17, 2010
    #2
    1. Advertising

  3. Jah_Alarm

    Eric Brunel Guest

    In article
    <>,
    Jah_Alarm <> 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 -
     
    Eric Brunel, Aug 17, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Philippe C. Martin

    Tkinter zoom box = maximize/unmaximize box/button

    Philippe C. Martin, Jan 3, 2005, in forum: Python
    Replies:
    1
    Views:
    578
    Eric Brunel
    Jan 3, 2005
  2. Tuvas

    Tkinter- Building a message box

    Tuvas, Nov 7, 2005, in forum: Python
    Replies:
    5
    Views:
    767
    Ron Adam
    Nov 7, 2005
  3. Replies:
    0
    Views:
    373
  4. Guilherme Polo
    Replies:
    0
    Views:
    512
    Guilherme Polo
    Aug 28, 2008
  5. Replies:
    0
    Views:
    525
Loading...

Share This Page