This is a piece of my code, I run the callback every time I press the ok button on my pop-up so I only want count to be defined once. After that I need to exclude the line "count = 0" from being looped. When I put it outside of the loop, even using global, it gives me an error saying it doesn't know what count is. Any way I could fix this? (Here is my code)
def callback():
count = 0
value = int(entry_field.get())
entry_field.delete("0", tk.END)
if value in plusOne:
count += count + 1
print(count)
Thanks
define it as global?:
count = 0
def callback():
global count
value = int(entry_field.get())
entry_field.delete("0", tk.END)
if value in plusOne:
count += count + 1
print(count)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.