Aug-07-2021, 05:16 AM
(This post was last modified: Aug-07-2021, 08:07 AM by Yoriz.
Edit Reason: Added prefix
)
So i have an integer 'bankValue' that is increased by a function 'addToBank'.
The buttons text displays 'bankValue', and should update upon click, but doesn't.
I don't need it to display on the button either, if I can have that number display anywhere that would be awesome.
Thank you!
- Skata100
The buttons text displays 'bankValue', and should update upon click, but doesn't.
from tkinter import *
import tkinter.messagebox as mb
import os
# the in-game bank value, your total 'currency'
bankValue = 0
# function that decides how much to add to bankValue
def addToBank(amount):
global bankValue
bankValue += amount
# "gameWindow" = tk interface
gameWindow = Tk()
# heightxwidth of interface
gameWindow.geometry("500x250")
# title on top bar
gameWindow.title("WTFIT v0.05")
# button click = bankValue + amount (amount can be changed)
button1 = Button(gameWindow, command=addToBank(1), text=bankValue, width = 10, height = 2, bg = 'cyan')
# placement of button
button1.place(x=100, y=25)
# shows whats happening
gameWindow.mainloop()I want the button to increase the value of 'bankValue', and display it as well.I don't need it to display on the button either, if I can have that number display anywhere that would be awesome.
Thank you!
- Skata100
