Python Forum
.get() invoke after a button nested press
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.get() invoke after a button nested press
#4
Thanks for your notes.

I have a main window

MainMenuWindow = tk.Tk()

tk.Button(MainMenuWindow,text = "login", fg = "black", width = "25", height = "1", command= partial(UserLogin2,MainMenuWindow)).grid(row = 13, column = 0,padx = 5, pady = 5,columnspan = 1)

tk.mainloop()



also this

def UserLogin2(MainMenuWindow):
attempt_made = False
user_record = ['someblankerrortext']

global login_verified
global run_program
global logged_in_user_record

login_verified = False
run_program = True
logged_in_user_record = [0,"","",0]

while login_verified == False and run_program == True:

LoginWindow = tk.TopLevel()
tk.Label(LoginWindow,text = "Please login with you Username and Password").grid(row = 0, column = 0,columnspan = 2, padx = 100, pady = 10)

if attempt_made:
tk.Label(LoginWindow,fg="red",text = "Incorrect username and/or password").grid(row = 5, column = 0,columnspan = 2)

tk.Label(LoginWindow,text = "Username: ").grid(row = 10, column = 0)
username = StringVar()
tk.Entry(LoginWindow,textvariable = username).grid(row = 10, column = 1)

tk.Label(LoginWindow,text = "Password: ").grid(row = 11, column = 0 )
password = StringVar()
tk.Entry(LoginWindow,textvariable = password,show = "*").grid(row = 11, column = 1)

tk.Button(LoginWindow,text = "OK", fg = "black", width = "25", height = "2", command= partial(UserLoginCheckPassword,username,password)).grid(row = 20, column = 0,padx = 5, pady = 0,columnspan = 1)

tk.Button(LoginWindow,text = "Quit", fg = "black", width = "25", height = "2", command= partial(LoginQuit,LoginWindow)).grid(row = 20, column = 1,padx = 5, pady = 0,columnspan = 1)

tk.mainloop()

attempt_made = True

return logged_in_user_record[0]



and


def UserLoginCheckPassword(input_username,input_password,):

global logged_in_user_record

username = input_username.get()
password = input_password.get()

print("\n\nin_user",input_username,", user "+username)
print("in_psw",input_password,", pswd "+password+"\n\n")

db_connect = sqlite3.connect(database_name) #connects to the database
db_cursor = db_connect.cursor()
db_cursor.execute("SELECT * FROM "+user_ID_table+" WHERE username == '" + username + "' AND password == '"+password+"'")
user_record = db_cursor.fetchall() #selects user record where password and username match and saves it as user_record

global login_verified

if user_record == []: #if the username and password do not match in a record then there data will not be stored.
login_verified = False
else:
login_verified = True
logged_in_user_record = user_record

return





if i run
UserLogin2()

NOT from the login button, but instead from the main code, it works, i have a box, ask 2 entry fields, its check the database, if its wrong, an error message is shown, and repeats until its correct, then returns the user record.

However if i run UserLogin2() from a menu button press, it does not have any value in the get().

i have changed the code to use tk.xxxxx

and some other changes

i have looked at simple dialog, but that is only 1 text entry fields

this is where i am stuck please!

however, if i
Reply


Messages In This Thread
RE: .get() invoke after a button nested press - by iddon5 - Mar-28-2021, 08:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter.TclError: can't invoke "canvas" command cybertooth 8 6,245 Feb-23-2023, 06:58 PM
Last Post: deanhystad
  [Tkinter] _tkinter.TclError: can't invoke "destroy" command: application has been destroyed knoxvilles_joker 6 15,966 Apr-25-2021, 08:41 PM
Last Post: knoxvilles_joker
Question closing a "nested" window with a button in PySimpleGUI and repeating this process Robby_PY 9 13,767 Jan-18-2021, 10:21 PM
Last Post: Serafim
  tkinter touchscreen scrolling - button press makes unwanted scrolling nanok66 1 4,087 Dec-28-2020, 10:00 PM
Last Post: nanok66
  Anytime I press the button, the result is depicted Jionni 2 2,283 Feb-24-2020, 10:08 AM
Last Post: Jionni
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,086 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] how to input a random entry with each button press? nadavrock 1 6,495 Jun-17-2019, 05:28 AM
Last Post: Yoriz
  [Tkinter] Spawn sub-window with button press malonn 3 5,952 Oct-28-2018, 02:56 PM
Last Post: malonn
  [Tkinter] Updating Label After Button Press malonn 7 5,820 Aug-23-2018, 10:52 PM
Last Post: malonn
  [Tkinter] Problem with changing label text on button press xk2006x 1 5,629 Jun-02-2017, 06:00 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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