0

Here is loginPage function code

import tkinter as tk

def loginPage(self):
    login_screen = tk.Tk()
    login_screen.title("Login")
    login_screen.geometry("300x250")
    tk.Label(login_screen, text="Please enter login details").pack()
    tk.Label(login_screen, text="").pack()
    tk.Label(login_screen, text="Username").pack()
    self.username_login_entry = tk.Entry(login_screen, textvariable="username")
    self.username_login_entry.pack()
    tk.Label(login_screen, text="").pack()
    tk.Label(login_screen, text="Password").pack()
    self.password_login_entry = tk.Entry(login_screen, textvariable="password", show='*')
    self.password_login_entry.pack()
    tk.Label(login_screen, text="").pack()
    tk.Button(login_screen, text="Login", width=10, height=1, command=lambda x=self.username_login_entry.get(), y=self.password_login_entry.get(): mainLogin().verifyLogin(x, y)).pack()
    login_screen.mainloop()

here is my verify login function code

    def verifyLogin(self, uname, pword):

    try:
        import python_to_postgres as pp
        global checkUserEst
        print('user nad pass!!! ', uname, pword)
        #ETO UNG MAY PROBLEM DIKO MAKIHA UNG VALUE MULA TKINTER ENTRY
        self.checkUser = pp.pyPostgre().loginAuth(uname, pword)

is there any other ways on how to pass the value of an entry widgets into the other function?

1
  • You don't need the lambda arguments with default values. Call those .get() inside the function instead. Commented Jan 22, 2022 at 11:35

1 Answer 1

1

I fixed it by using lambda. see the code below.

command=lambda a=0, b=0: mainLogin().verifyLogin(self.username_login_entry.get(), self.password_login_entry.get())
Sign up to request clarification or add additional context in comments.

2 Comments

What the point of the two arguments a and b? They are not necessary at all.
I don't know how that works behind but whenever I use lambda together with function that requires parameter/s it doesn't execute right away It will wait for the button to be pressed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.