I'm trying to make an ordinary click counter with a GUI based on the Tkinter library. Code like this:
count = 0 from tkinter import * from tkinter.ttk import * def printer(event): #ΠΡΠΈ ΠΊΠ»ΠΈΠΊΠ΅ count += 1 #Π‘ΠΎΠ±ΡΡΠΈΠ΅ self = Tk() button = Button(self, text='CLICK ME PLS') button.pack() lab = Label(self, text= count, font="Tahoma") lab.pack() button.bind('<Button-1>', printer) self.mainloop() The program swears at:
count += 1 And writes:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\ElPI-25\AppData\Local\Programs\Python\Python36- 32\lib\tkinter\__init__.py", line 1699, in __call__ return self.func(*args) File "D:/ΡΠ°Π±ΠΎΡΠΈΠΉ ΡΡΠΎΠ»/ΠΡΠΎΠ΅ΠΊΡΡ ΠΡΡΠ΅Π½ΠΈΡ/TK.py", line 9, in printer count += 1 UnboundLocalError: local variable 'count' referenced before assignment Urgently help, please.