我无法使标签交互变化

时间:2019-04-14 20:48:15

标签: python function tkinter

当我单击按钮时,我想使标签变化。但是当我单击时,什么也没发生。

我尝试使用textvariable,普通文本.config方法。但似乎没有任何作用

from tkinter import *

global Forca
Forca = 0

def ad_for():
    global Forca
    Forca += 1
    show_forca['text'] = Forca

def hp():
    global vida
    vida = Forca + 10
    show_ferimentos['text'] = vida

ficha = Tk()
caracteristicas = Frame()
caracteristicas.grid(row=1,column=0)

forca = Label(caracteristicas, text='FORÇA FÍSICA')
forca.grid(row=0,column=0)
show_forca = Label(caracteristicas,text='-')
show_forca.grid(row=0,column=1)
b_forca = Button(caracteristicas,text='+',command=ad_for)
b_forca.grid(row=0,column=2)

recursos = Frame()
recursos.grid(row=1,column=1)
ferimentos = Label(recursos,text='FERIMENTOS')
ferimentos.grid(row=0,column=0)
show_ferimentos = Label(recursos,text=hp)
show_ferimentos.grid(row=0,column=1)

ficha.mainloop()

我希望通过单击b_forca按钮,可以交互地修改标签show_ferimentos

0 个答案:

没有答案