我有一个任务日历python程序,允许用户输入年份和月份,然后显示月份日历以及任何任务及其到期日期。
但是当我尝试调用方法和tkMessageBox时出现错误 这是我的代码。
import calendar
from tkinter import *
import tkMessageBox
event = [8,10,17,21,29]
master = Tk()
Label(master, text =" Enter Year:").grid(row=0)
Label(master, text ="Enter Month").grid(row=1)
yy = Entry(master)
mm = Entry(master)
yy.grid(row = 0, column = 1)
mm.grid(row = 1, column = 1)
Button(master, text = 'Exit', command = master.exit).grid(row = 3, column = 0, sticky = W, pady = 4)
Button(master, text = 'Submit', command = paybill(nn)).grid(row = 3, column = 1, sticky = W, pady = 4)
mainloop()
#yy = int(input())
#mm = int(input())
#dd = int(input("Enter day: "))
print(calendar.month(yy,mm))
def bday(dd,mm):
if(dd == 21 and mm == 2):
print("Happy Birthday!")
else:
print("Unhappy Birthday!")
def paybill(nn):
items = ["Insurance", "Netflix" , "Cell Phone"]
if(nn == 2 or nn == 3):
tkMessagBox.show(title="Calendar", message = str(items[0]) + " is due:" + " " + str(event[4]) + "th")
elif(nn == 4 or nn == 5):
print(str(items[0]) + " is due:" + " " + str(event[4]) + "th")
print(str(items[2]) + " is due:" + " " + str(event[2]) + "th")
else:
print("Nothing is due this month")
#paybill(mm)
#e = str(input("Would You like to enter a new entry?"))
#def entry_date(e):
#ne = []
# if e == "Yes":
# int(input("Enter a date:"))
# event.append(e)
#
# str(input("Enter a task"))
# ne.append(e)
# elif e == "No":
# print("No entry was added.")
#entry_date(e)
input ("Press Enter to Exit")
答案 0 :(得分:1)
.show
似乎不是tkMessageBox
的有效功能。请尝试以下之一。
showinfo()
showwarning()
showerror()
askquestion()
askokcancel()
askyesno()
askretrycancel()
另见:
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/tkMessageBox.html