#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0

    Question Tkinter Reminder MessageBox Show up


    Hi everyone,

    I am trying to create a reminder using Tkinter.

    I can give the appropriate time and the same time change a label's text,but I want to show up a MessageBox,too.

    My code is below:
    (I am get an error like: "TkMessageBox not defined")

    Code:
    from Tkinter import *
    import time
    import tkMessageBox
    
    form1=Tk()
    form1.title('Project')
    form1.resizable(width=FALSE, height=FALSE)
    form1.geometry('1032x680+200+200')
    
    time1 = ''
    clock = Label(form1, font=('times', 20, 'bold'), bg='red')
    clock.pack(fill=BOTH, expand=1)
    def tick():
        global time1
        time2 = time.strftime('%H:%M:%S')
        if time2 != time1:
            time1 = time2
            clock.config(text=time2)
        clock.after(200, tick)
    tick()
    reminder = Label(form1, font=('remind', 20, 'bold'),bg='green')
    reminder.pack(fill=BOTH , expand=1)
    reminder.config(text="o reminder")
    def hour():
        global x,y,z
        x=float(time.strftime("%H"))
        y=float(time.strftime("%M"))
        z=float(time.strftime("%S"))
        if y==37: reminder.config(text="First")
        if y==38:                       
            reminder.config(text="Second") 
            tkMessageBox.showinfo(text='Something',message='Else') 
        reminder.after(200,hour)
        
    hour()
    
    form1.mainloop()
    If I comment the:

    Code:
      tkMessageBox.showinfo(text='Something',message='Else')
    ..everything is ok.

    But how can I show up a Messagebox...??


    Thanks in advance.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,709
    Rep Power
    480
    Use a multi-line label.

    How about the tkinter Dialog?

    >>> import tkinter.messagebox as MB
    >>> MB.askyesno()
    False
    >>>
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    13
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Use a multi-line label.

    How about the tkinter Dialog?

    >>> import tkinter.messagebox as MB
    >>> MB.askyesno()
    False
    >>>
    You mean I have to use a tkMessageBox..?
    (I have already used it but I am getting error.....
    **Sorry in my code i forgot to import MessageBox..I am going to edit it right now**)

    I want to show up a MessageBox rathen than a label, because it will be more useful for the user.

    What is the use of False on your code...?


    Thanks.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,709
    Rep Power
    480
    Please read manuals to find out what is available.

    Please spend enough time using the python interpreter so you can distinguish the python prompt, the programmers' input, and python output.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo