[英]How do I create a button in Python Tkinter to increase integer variable by 1 and display that variable?
[英]How to increase a variable in tkinter,python
我正在嘗試在 function 中增加一個變量,但我找不到如何使用 tkinter var 來執行此操作,代碼如下:
counter = IntVar()
counter.set(0)
def addonclick (button1):
entryBox.insert(counter.get(),button1)
counter
嘗試這個:
counter = IntVar()
counter.set(0)
def addonclick (button1):
counter.set(counter.get()+1)
entryBox.insert(counter.get(),button1)
print(counter.get())
#output--> 1
希望它會幫助你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.