calfred2808

#Python Autologin

Jul 19th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. # importing the tkinter module
  2. from tkinter import *
  3.  
  4. # defining a function
  5. def fun():
  6.     # defining autologin function and upon calling this function        
  7.     # values for username and password will be autowritten
  8.     def autologin():
  9.         # setting username as coding community
  10.         username.set("coding community")
  11.         # setting secret password
  12.         password.set("****************")
  13.  
  14.     # initializing tkinter
  15.     login_screen = Tk()
  16.  
  17.     # setting gui title
  18.     login_screen.title("Auto login with python")
  19.     # setting gui geometry
  20.     login_screen.geometry("300x250")
  21.  
  22.     # creating a text label widget and packing it
  23.     Label(login_screen, text="Please enter login details").pack()
  24.  
  25.     # creating a text label widget and packing it
  26.     Label(login_screen, text="Username").pack()
  27.     # declaring a string type variable to store username from
  28.     # entry widget
  29.     username = StringVar()
  30.  
  31.     # declaring a string type variable to store password from
  32.     # entry widget
  33.     password = StringVar()
  34.  
  35.     # creating a entry widget to take username
  36.     username_login_entry = Entry(login_screen, textvariable=username)
  37.     # packing entry widget on gui screen
  38.     username_login_entry.pack()
  39.  
  40.     # creating a text label widget and packing it
  41.     l1 = Label(login_screen, text="Password").pack()
  42.  
  43.     # creating an entry widget to take password from user
  44.     password_login_entry = Entry(login_screen, textvariable=password)
  45.  
  46.     # packing the entry widget
  47.     password_login_entry.pack()
  48.  
  49.     # adding button to application screen to call autologin    
  50.     # function
  51.     Button(login_screen, text="Apply auto fill", command=autologin).pack()
  52.    
  53.     # adding button to applicaton screen to ask user to login
  54.     Button(login_screen, text="Login Now", width=10, height=1).pack(pady=10)
  55.  
  56.     # running the mainloop when the code is ready
  57.     login_screen.mainloop()
  58.  
  59. fun()
Add Comment
Please, Sign In to add comment