Pretty new to Python, but I have some background in C and VB. Just joined this site because I couldn't find anywhere else to get Python help!
I'm working with VPython in the IDLE environment, and I'm having a problem changing a variable using a toggle switch and a function. Here's the necessary parts:
mode = 0
def switchMode():
if t1.value:
mode = 1
else:
mode = 0
tMoGen = toggle(pos=(40,-30),width=10,height=10,text0='Off',text1='On',action=lambda: switchMode())
while True:
rate(5)
c.interact()
print mode
Mode just stays at 0, no matter how many times I flip the switch.
I think I may need to return the value out of the function, but I'm not sure how to do that yet.