本文介绍了使用Tkinter将一个按钮绑定到两个事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始编程,正在制作井字游戏程序.在我的程序中,我具有显示功能,该功能可以更改并确保输入的内容有效,并具有赢奖检查器.有没有办法将这两个功能都绑定到Enter键?

I am just getting started with programming and am making a Tic-Tac-Toe program. In my program I have a display function, which changes and makes sure what entered is valid, and a win checker. Is there a way that I can bind both of these functions to the enter key?

类似的东西:

RowEnt.bind("<Return>", display, checkWin)

推荐答案

您可以将两个函数嵌套在另一个函数中:),例如:

you could nest both functions inside of another function :) for example:

def addone(num1):
    num1=int(num1)+1

def subtractone(num1):
    num1=int(num1)-1

def combine():
    addone(1)
    subtractone(1)

如果您想同时调用它们,只需将combine()用作调用的函数即可:)

if you wanted to call both of them, you would simply use combine() as the function you call :)

这篇关于使用Tkinter将一个按钮绑定到两个事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:27