Python Log Screen Bug
Solution 1:
The problem is because the username
and the password
variables are in the main block and when you run the code the entry boxes are empty(initially) which assigns ''
to the variables. So to overcome that you should assign the variables inside the function, where now the values of the filled entry box is only taken.
Code:
from tkinter import *
from tkinter import messagebox
login_page = Tk()
login_page.title("login_page")
login_page.geometry("250x110")
defcheck_pass():
username = log_name.get()
userpass = log_pass.get()
if username == name and userpass == password:
messagebox.showinfo('Successfull','Login successfull')
else:
choice = messagebox.askretrycancel("Try again","Wrong password ")
if choice == True:
passelse:
login_page.destroy()
......
# ALL THE SAME LINES OF CODE TILL
name = "admin"
password = "admin"
login_page.mainloop()
Also since your using a messagebox like askretrycancel
, you can do certain action based on the choice by the user. So here I have said if the user clicks on retry, then ask them to login again, or else close the application. You can change it to whatever you like(or even remove it too.)
And also it is recommended to say login_page.mainloop()
, just so that tkinter isnt confused at any later steps.
Hope your "bug" is cleared and do let me know if any errors :D
Cheers
Post a Comment for "Python Log Screen Bug"