Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.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 ";按钮";。config()不';我的代码不起作用_Python_Tkinter_Python 3.7 - Fatal编程技术网

Python ";按钮";。config()不';我的代码不起作用

Python ";按钮";。config()不';我的代码不起作用,python,tkinter,python-3.7,Python,Tkinter,Python 3.7,因此,我试图通过使用.config()命令按下按钮来刷新标签,但根本不起作用。我不知道如何使它正常工作。(应该尽可能简单) 您应该指定将来使用的库(我认为它是tkinter?),并提供一个最小的、完整的、可验证的示例()。什么“不起作用”?有错误吗?事情是否没有展现出你想要的样子 不要将根窗口传递给.config方法。.config方法在之前作用于对象,因此它已经知道关于该对象的所有元数据 show\u score.config中的text关键字参数的值看起来不正确。首先,您可能需要将score

因此,我试图通过使用.config()命令按下按钮来刷新标签,但根本不起作用。我不知道如何使它正常工作。(应该尽可能简单)


您应该指定将来使用的库(我认为它是tkinter?),并提供一个最小的、完整的、可验证的示例()。什么“不起作用”?有错误吗?事情是否没有展现出你想要的样子

不要将根窗口传递给
.config
方法。
.config
方法在
之前作用于对象,因此它已经知道关于该对象的所有元数据

show\u score.config
中的
text
关键字参数的值看起来不正确。首先,您可能需要将
score
声明为
refresh\u score
中的全局变量,就像在
points
中一样。其次,您试图将
text
关键字参数设置为包含字符串和整数的元组,但它应该仅为一个字符串。试试
text=“Score:+str(Score)
。您还应该在定义
show_score
时更改此选项:
show_score=Label(root,text=“score:+str(score))

def points():
    global mode,score,show_score
    if mode==0:
        score=0
    else:
        score=score+1
    if score==1:
        show_score=Label(root,text=("Score:",score))
        show_score.pack()

def refresh_score():
    global show_score
    show_score.config(root,text=("Score:",score))`enter code here`