【发布时间】:2020-08-08 19:08:08
【问题描述】:
我想创建一个按钮,显示你在按下它时按下了多少次。
但我不知道每次按下它时如何“刷新”它。
有人可以帮我吗?
from tkinter import *
class Press():
def __init__(self):
self.root = Tk()
self.scale = self.root.wm_minsize(width=500, height=300)
self.changer = StringVar()
self.changer.set(0)
self.label = Label(self.root , textvariable= self.changer)
self.button = Button(self.root, text="PRESS", command= self.amount_pressed)
self.button.pack()
self.label.pack()
self.mainloop = mainloop()
def amount_pressed(self):
self.changer.set(+1)
test = Press()
【问题讨论】: