То, что вы пытаетесь сделать, кажется, что-то сделано для приложения. Чтобы решить вашу проблему, я считаю, что вам нужно создать переменную в вашем классе MainWindow (если это так, если вы работаете с настольным приложением).
Таким образом, класс MainWindow должен выглядеть примерно так this:
## Main Window Class
class MainWindow(object):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
# Declare here your login counter variable
self.loginCounter = 0
В этом смысле вам необходимо добавить переменную self.loginCounter , подобную этой, в логине вашего логина c:
if username_ask in col0:
for k in range(0, len(col0)):
if col0[k] == username_ask and col1[k] == "b'"+text+"'":
messagebox.showinfo('Welcome, '+username_ask,'You succesfully logged in to your account: '+username_ask)
logincorrect == True
found = True
root.destroy()
sys.exit()
count = 0
else:
found = False
else:
messagebox.showerror('Incorrect','The credinetials you entered are incorrect, please try again.')
## If this part of the code is **inside** the MainWindow Class use:
self.loginCounter += 1
## If this part of the code is **outside** the MainWindow Class use:
MainWindow.loginCounter +=1
break
else:
messagebox.showerror('Error 404: Not found.','The credentials you enetered do not exist, please try again.')
sys.exit()
Позвольте мне знать, если это помогает! Удачи!