如何在Tkinter中获取具有2个命令的按钮 [英] How to get a button to have 2 commands in Tkinter

查看:198
本文介绍了如何在Tkinter中获取具有2个命令的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码行:
nu和apendin命令由于某些原因无法正常工作。如果我删除其中一个但它们不能一起工作,则可以使用。有关如何解决此问题的任何想法。

I have this line of code: nu and apendinThe commands are not working for some reason. It works if I remove one of them but they do not work together. Any idea on how to fix this.

谢谢x

推荐答案

您可以尝试一些方法像这样使用 lambda 函数

You can try something like this using lambda function

login_button = Button(root, text="Click here to enter data", command=lambda:[main_menu(),apending_to_text_file()])

这篇关于如何在Tkinter中获取具有2个命令的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆