【发布时间】:2014-06-28 00:11:21
【问题描述】:
您好,我已经启动了一个程序来显示我的学校时间表,这是我目前的代码:
from tkinter import *
master = Tk()
master2 = Tk()
var = StringVar(master)
var2 = StringVar(master2)
var.set("Day")
var2.set("Week")
option = OptionMenu(master, var, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
option2 = OptionMenu(master2, var, "A", "B")
option.pack()
option2.pack()
Week = var2.get()
Day = var.get()
def ok():
if Day == "Monday" and Week == "A":
print("You have: \n P.S.E with Mrs Smith \n W.B.Q with Mrs Smith \n Science with Mr Martin \n Media wirh Mr Kelleher \n English with Mrs Jenkins (of mice and men)")
input("Press enter to close")
if Day == "Tuesday" and Week == "A":
print("You have: \n R.M with Mr Arnold/Mr Heywood \n English with Mrs Jenkins \n I.C.T with Mr Davies \n Maths with Mr Tucker \n I.T programing with Mr Arnold ")
input("Press enter to close")
if Day == "Wednesday" and Week == "A":
print("You have: \n English with Mrs Jenkins \n Science with Mr Martin \n Re with Mr Davies \n Media with Mr Kelleher \n R.M with Mr Arnold/Mr Heywood ")
input("Press enter to close")
if Day == "Thursday" and Week == "A":
print("You have: \n Games With Mr Davies \n I.C.T with Mr Davies \n I.T programing with Mr Arnold \n Science with Mr Martin \n Maths with Mr Tucker")
input("Press enter to close")
if Day == "Friday" and Week == "A":
print("You have: \n Maths with Mr Tucker \n English with Mrs Jenkins \n Media with Mr Kelleher \n I.T programing with Mr Arnold \n Science with Dr Burton")
input("Press enter to close")
if Day == "Monday" and Week == "B":
print("You have: \n Science with Dr Burton \n Re with Mr Davies \n Welsh with Mr Kedward \n English with Mrs Jenkins (of mice and men) \n Media with Mr Kelleher")
input("Press enter to close")
if Day == "Tuesday" and Week == "B":
print("You have: \n Maths with Mr Tucker \n R.M with Mr Arnold/Mr Heywood \n I.T programing with Mr Arnold \n I.C.T with Mr Davies \n Science with Dr Burton")
input("Press enter to close")
if Day == "Wednesday" and Week == "B":
print("You have: \n R.M with Mr Arnold/Mr Heywood \n Media with Mr Kelleher \n English with Mrs Jenkins \n Science with Miss Fair \n I.C.T with Mr Davies")
input("Press enter to close")
if Day == "Thursday" and Week == "B":
print("You have: \n Games With Mr Davies \n I.C.T with Mr Davies \n I.T programing with Mr Arnold \n Maths with Mr Tucker \n Science with Miss fair")
input("Press enter to close")
if Day == "Friday" and Week == "B":
print("You have: \n Welsh with Mr Kedward \n Science with Miss Fair \n English With Mrs Jenkins \n Maths with Mr Tucker an R.M with Mr Arnold/Mr Heywood")
input("Press enter to close")
else:
print("Error invalid choice")
input("Press enter to close")
button = Button(master, text="OK", command=ok)
button2 = Button(master2, text="OK", command=ok)
button.pack()
button2.pack()
mainloop()
我想知道如何在同一个 Tkinter 窗口中显示这两个选项,它也没有将值设置为正确的值,例如:Day does not = Monday 并且 Week does not = A 相反他们 = "day week" 和我想知道如何解决这个谢谢。我也是新手 tkinter
【问题讨论】: