使用Tkinter模块,我尝试根据某个选项菜单的某个选择引发一个操作,如果选项菜单不在指定的选项上,则取消该操作。问题是程序将被编译,除非两个选项menu=“treble clef”都有点停止工作。我尝试过使用if语句,但我不确定如何去掉它调用的标签。在
originalKey = Label(window, text = "Original Key Signature", bg = 'black', fg = 'white')
originalKey.pack()
oKey = StringVar(window)
oKey.set("Select") # initial value
optionold = OptionMenu(window, oKey, "treble clef", "bass clef", "alto clef")
optionold.config(bg = 'black', fg = 'white')
optionold.pack()
#new key selections option menu
def displayKey(str):
while nKey.get() == "treble clef" and oKey.get() == "treble clef":
testpic = Label(window, image = logoimage, bg = 'black')
testpic.pack()
break
newKey = Label(window, text = "New Key Signature", bg = 'black', fg = 'white')
newKey.pack()
nKey = StringVar(window)
nKey.set("select") # initial value
optionnew = OptionMenu(window, nKey, "treble clef", "bass clef", "alto clef",
command = displayKey)
optionnew.config(bg = 'black', fg = 'white')
optionnew.pack()
目前没有回答
相关问题 更多 >
编程相关推荐