def write_lor():
with open("data.txt", 'r+') as filehandle:
filecontents = filehandle.readlines()
filehandle.seek(0)
new = (int(filecontents[0])+1)
filehandle.write(str(new))
filehandle.truncate()
This is a basic counter sort of system that saves to a txt. Is there anyway to reference the variable new
later down the line? For example my usage is:
button1 = Button(frame, text=("Left On Read:\n", **VARIABLE**), fg="black", bg="white", height = 5, width = 20, command=write_lor)
with the variable needing to be the variable new
referenced in the function above.