如何在单击一个按钮时运行两个命令?
def commend1():
print "hi"
def commend2():
print "hello"
#TKinter
button = Button(root, commend= ?)
我希望它们同时运行
答案 0 :(得分:2)
最基本的答案是:
def commend1():
print "hi"
def commend2():
print "hello"
def cmd12():
commend1()
commend2()
#TKinter
button = Button(root, command=cmd12)
答案 1 :(得分:0)
您可以像这样通过commend1()调用commend2():
def commend1():
print "hi"
commend2()
def commend2():
print "hello"
#TKinter
button = Button(root, command= commend1)