有没有办法在tkinter/python上按下按钮而不用触摸它? [英] Is there a way to press a button without touching it on tkinter / python?

查看:45
本文介绍了有没有办法在tkinter/python上按下按钮而不用触摸它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要这样做,因为我正在制作一个匹配/记忆游戏,并且必须有一个按钮(与当前游戏中的按钮完全分开),当我按下该按钮时,它必须显示匹配项自动存储卡,而无需用鼠标触摸按钮.

Hi I need to do this because, I am making a matching / memmory game, and there has to be a button (Totally separated from the ones on the current game) that when I press it, it has to show the matching cards automatically without having to touch the buttons with the mouse.

是否有按下"功能或类似的用于按下按钮的功能?

Is there a "press" function or something like that for pressing the button?

谢谢!:)

推荐答案

正如Joel Cornett在评论中建议的那样,简单地调用传递给按钮的回调可能更有意义.但是,如文档, Button.invoke()方法将具有与按下按钮相同的效果(并返回回调的结果),略微的优点是,如果按钮为当前已禁用或没有回调.

As Joel Cornett suggests in a comment, it might make more sense to simply call the callback that you passed to the button. However, as described in the docs, the Button.invoke() method will have the same effect as pressing the button (and will return the result of the callback), with the slight advantage that it will have no effect if the button is currently disabled or has no callback.

这篇关于有没有办法在tkinter/python上按下按钮而不用触摸它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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