Python AttributeError:缺少绑定

Python AttributeError:缺少绑定,python,bind,attributeerror,vpython,Python,Bind,Attributeerror,Vpython,我试图用Vpyton模块创建一个按钮(由于某些原因而不是tkinter),但出现了以下错误:AttributeError:bind missing 什么是束缚,我怎样才能解决它 from vpython import * def change(): # Appelé par controls quand on clique sur le bouton if b.text == 'Click me': b.text = 'Try again' else:

我试图用Vpyton模块创建一个按钮(由于某些原因而不是tkinter),但出现了以下错误:AttributeError:bind missing

什么是束缚,我怎样才能解决它

from vpython import *
def change(): # Appelé par controls quand on clique sur le bouton
    if b.text == 'Click me':
        b.text = 'Try again'
    else:
        b.text = 'Click me'

c = controls() # Crée une fenêtre pour les contrôles
# Crée un bouton dans la fenêtre des contrôles:
b = button( pos=(0,0), width=60, height=60, 
          text='Click me', action=lambda: change() )
while 1:
    c.interact()

根据下面的例子

这是电话线

cbutton=按钮(text='Red',textcolor=color.Red,background=color.cyan,pos=scene.title\u锚定,bind=color)

所以看起来您需要向按钮添加bind属性

b=按钮(位置=(0,0),宽度=60,高度=60, text='Click me',action=lambda:change(),bind=change)

来自VPython 7中有关按钮和小部件的文档

它说按钮的bind属性是


“绑定单击按钮时要调用的函数的名称。创建按钮后无法更改。”

哪一行给出了错误?此外,张贴的空白看起来不正确。这正是导致问题的代码吗?似乎visual.controls import*中缺少了
,正如官方指南所说:提示:始终用英语记录代码。假设您制作了一些非常有用的代码并与他人共享,想象一下其他不使用该语言的开发人员将遇到的困难。@Fusseldieb:对不起,您是对的。我会为下一次努力的time@Torxed:我以前尝试过此代码,但出现了此错误:ModuleNotFoundError:没有名为“visual”的模块我在stackoverflow上查找它,发现了此主题:表示必须用vpython替换visual,但vpython没有名为controls的模块。。。