Python Forum
[Tkinter] Login Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Login Help
#1
I need help figuring out my code as it is not running after this part (Line 49), where it shows, "Welcome..." any thoughts??
t=0
#Authentication Page
from tkinter import *
import tkinter.messagebox as tm
class LoginFrame(Frame):
    def __init__(self, master):
        super().__init__(master)
        print("Welcome to the Weather Engine. Please enter your seven digit Forecaster ID Number followed by your password.")
        self.label_username = Label(self, text="Forecaster ID")
        self.label_password = Label(self, text="Password")

        self.entry_username = Entry(self)
        self.entry_password = Entry(self, show="X")

        self.label_username.grid(row=0, sticky=E)
        self.label_password.grid(row=1, sticky=E)
        self.entry_username.grid(row=0, column=1)
        self.entry_password.grid(row=1, column=1)

        self.checkbox = Checkbutton(self, text="Remember Me")
        self.checkbox.grid(columnspan=2)

        self.logbtn = Button(self, text="Login", command=self._login_btn_clicked)
        self.logbtn.grid(columnspan=2)

        self.pack()
    def _login_btn_clicked(self):
        # print("Clicked")
        username = self.entry_username.get()
        password = self.entry_password.get()

        # print(username, password)
        if username == "12141" and password == "7777":
            tm.showinfo("Login info", "Welcome Admin")
            forecaster="Admin"
            t=1
            
        if username == "25101" and password == "12345":
            tm.showinfo("Login info", "Welcome User1")
            t=2
    

root = Tk()
lf = LoginFrame(root)

root.mainloop()
if t != str(0):
     print("Hello " + forecaster + ", What do you want to do?")
     
Output:
"Welcome Forecaster"
Thank you in advance Smile
Reply
#2
root.mainloop() runs an infinite loop until all GUI windows are closed,
it won't move onto the line
if t != str(0):
until you close all GUI windows.
Also, your code shown has no line 49 Huh
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020