Home > Mobile >  how can I pass the value of tkentry widgets into other function using python
how can I pass the value of tkentry widgets into other function using python

Time:01-23

Here is loginPage function code
*` def loginPage(self): import tkinter as tk 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?

CodePudding user response:

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())

CodePudding user response:

I think it'll be easier if you show a bit more of your code, but in the meantime, have you tried something like:

  password = password_login_entry.get()? 

(Using my phone, hence no formatting)

  •  Tags:  
  • Related