为了账号安全,请及时绑定邮箱和手机立即绑定

python tkinter,如何在单击一个按钮时运行两个命令?

python tkinter,如何在单击一个按钮时运行两个命令?

临摹微笑 2021-06-11 18:27:59
如何单击一个按钮运行两个命令?例子:def commend1():  print "hi"def commend2():  print "hello"#TKinterbutton = Button(root, commend= ?)我希望它们同时运行
查看完整描述

2 回答

?
至尊宝的传说

TA贡献1789条经验 获得超10个赞

最基本的答案是:


def commend1():

  print "hi"


def commend2():

  print "hello"


def cmd12():

  commend1()

  commend2()


#TKinter

button = Button(root, command=cmd12)


查看完整回答
反对 回复 2021-06-22
?
萧十郎

TA贡献1815条经验 获得超13个赞

你可以让你的commended1() 像这样调用commend2():


def commend1():

  print "hi"

  commend2()


def commend2():

  print "hello"


#TKinter

button = Button(root, command= commend1)


查看完整回答
反对 回复 2021-06-22
  • 2 回答
  • 0 关注
  • 124 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号