Jun-20-2021, 07:51 PM
Hi,
My placeholder works now but the problem lies with calling it in the SQL statement.
Without the placeholder, my SQL is working fine because each of my entry boxes have (example: textvariable="user") but when I place it in the configuration of my entry box the placeholder will also disappear. How can I make my placeholder works and also the SQL statement?
Thank you
My placeholder works now but the problem lies with calling it in the SQL statement.
Without the placeholder, my SQL is working fine because each of my entry boxes have (example: textvariable="user") but when I place it in the configuration of my entry box the placeholder will also disappear. How can I make my placeholder works and also the SQL statement?
Thank you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
class EntryWithPlaceholder(tk.Entry): def __init__( self , master = None , placeholder = "PLACEHOLDER" , color = 'grey' ): super ().__init__(master) self .placeholder = placeholder self .placeholder_color = color self .default_fg_color = self [ 'fg' ] self .bind( "<FocusIn>" , self .foc_in) self .bind( "<FocusOut>" , self .foc_out) self .put_placeholder() def put_placeholder( self ): self .insert( 0 , self .placeholder) self [ 'fg' ] = self .placeholder_color def foc_in( self , * args): if self [ 'fg' ] = = self .placeholder_color: self .delete( '0' , 'end' ) self [ 'fg' ] = self .default_fg_color def foc_out( self , * args): if not self .get(): self .put_placeholder() self .user_input = EntryWithPlaceholder(root, 'USERNAME OR EMAIL' ) self .user_input.place(relx = 0.18 , rely = 0.455 , width = 300 , height = 24 ) self .user_input.configure(font = ( "Corbel" , 15 )) self .user_input.configure(borderwidth = 0 ) self .user_input.configure(relief = "flat" ) def login( self , Event = None ): find_user = "SELECT * FROM employee WHERE ('username' : u OR email_address = %s) and password = %s" cur.execute(find_user, [user.get(), user.get(), passwd.get()]) results = cur.fetchall() if results: if results[ 0 ][ 10 ] = = "Admin" : messagebox.showinfo( "Login Page" , "The login is successful." ) page1.user_input.delete( 0 , END) page1.pass_input.delete( 0 , END) root.withdraw() global adm global page2 adm = Toplevel() page2 = Admin_Page(adm) # page2.time() adm.protocol( "WM_DELETE_WINDOW" , exitt) adm.mainloop() else : messagebox.showerror( "Oops!!" , "You are not an admin." ) else : messagebox.showerror( "Error" , "Incorrect username or password." ) page1.pass_input.delete( 0 , END) |