Right now I’m coding a turtle graphics program and for some reason, when I use the onkey method, it doesn’t modify the variable for future use. The function works, it just doesn’t apply it for later. How can I fix this?
Current code:
import turtle
import functools
a = False
b = False
def toggle():
global a
a^=True
print(a)
def func1(aNew, bNew):
actions = {1: [False, False],
2: [False, True],
3: [True, False],
4: [True, True],}
for i in actions:
if actions[i][0] == bNew and actions[i][1] == aNew:
print(actions[i][0], actions[i][1])
s.onkey(toggle, "p")
s.onkey(functools.partial(moveCheckWide, a, b), "r")
s.listen()
s.mainloop()
press r, p, then r
What it should return
False False
True
False True
What it ends up returning
False False
True
False False
What to do?