Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
from tkinter import *

x = 0

def val_Changer(x):
global z
z = x + 1
print(z)
return z


def root():
root = Tk()

val_Updater = Button(root, text="Update Value (+1)", width=25, height=4, bg="Red", fg="White", command=lambda:val_Changer(x))
val_Updater.place(x=75, y=125)

root.title("Value Updater")
root.geometry("350x350")
root.resizable(False, False)
root.mainloop()

root()

Above if the code i've listed that isn't seeming to work. I'm trying to build a quiz where if the user clicks the right button than the variable will update +1. If the user manages to get the variable to 10 than he gets 10 percent. If i cant get this small peice of code working i can make my quiz. Please help a young programmer out because i've been trying for 2 weeks and im frustrated. I've tried the tkinter.IntVar() but i cant pass it as an argument into another function to calculate the score. P.S Im using windows 10 on python 3.4 w/ tkinter
Posted
Comments
DeDenker 13-Jan-16 6:26am    
Why are you returning a global variable?

Please paste the code as code here, because now it doesn't seem as you are calling the updater correctly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900