Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 按下按钮_Python_Tkinter - Fatal编程技术网

Python 按下按钮

Python 按下按钮,python,tkinter,Python,Tkinter,我想在按下按钮时执行一个方法,在释放按钮时执行另一个方法。我在互联网上搜索了很多东西,不知道怎么做,我该怎么做?您可以使用以下示例将操作绑定到特定函数和释放上的都是函数,您不必使用()调用它们,它们将自动运行 button.bind("<ButtonPress>", on_press) button.bind("<ButtonRelease>", on_release) 按钮。绑定(“,按时) 按钮绑定(“,在发布时)

我想在按下按钮时执行一个方法,在释放按钮时执行另一个方法。我在互联网上搜索了很多东西,不知道怎么做,我该怎么做?

您可以使用以下示例将操作绑定到特定函数<按上的code>和释放上的
都是函数,您不必使用
()
调用它们,它们将自动运行

button.bind("<ButtonPress>", on_press)
button.bind("<ButtonRelease>", on_release)
按钮。绑定(“,按时)
按钮绑定(“,在发布时)