以下代码是将按钮附加到现有程序的程序,因此可以在更友好的界面上而不是在代码内部进行选择。我正在尝试使用下拉菜单,但 setEthAnt1 函数似乎有一个错误:TypeError: setEthAnt1() 不接受任何参数(给定 1)。我不知道我没有传入什么参数。有人有什么想法吗?
from Tkinter import *
import ThreegroupsGraphics as three
def run():
three.main()
def setEthAnt1():
name = var.get()
print name
three.OneTo2Ant = name
print three.OneTo2Ant
root = Tk()
var = StringVar()
var.set("Group 1 Ethnic Antagonism")
OptionMenu(root, var, "1","2","3","4","5","6","7","8","9","10", command = setEthAnt1).pack()
butn = Button(root, text = 'run', command = run)
butn.pack()
root.mainloop()