def login(): # executed when the login button is pressed, or return is pressed global isLogged # we use isLogged as a global, for other functions which won't work if the user isn't logged in try: # we try to get the variables required for logging in USR = usr.get() PWD = pwd.get() SRV = srv.get() # we assign isLogged to whatever login returns isLogged = TravianRaider.login(USR, PWD, SRV) except: pass if isLogged: # if the user successfully logged in, we send a positive message loggedLabel['foreground'] = "green" logged.set("Success!") # and then we clear the entry fields usr_entry.delete(0, 'end') pwd_entry.delete(0, 'end') displayIt() else: # if not, we send a negative message and we let the player # change his credentials loggedLabel['foreground'] = "red" logged.set("Failure!") timelib.sleep(2) logged.set("")
def login(*args): global isLogged try: USR = usr.get() PWD = pwd.get() SRV = srv.get() isLogged = TravianRaider.login(USR, PWD, SRV) except: pass