Guest User

Untitled

a guest
Aug 28th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. def log_in():
  4. def click_ok():
  5. username = usr_entry_var.get()
  6. password = pwd_entry_var.get()
  7.  
  8. # This is the portion that creates a connection instance
  9. # that I desire to later perform actions against in the
  10. # form of connection.doStuff()
  11. # I have just set it to some text here for brevity, as this
  12. # portion is working fine.
  13. connection = 'someStuffThatAuthenticates'
  14.  
  15. login.destroy()
  16.  
  17. login = tk.Toplevel()
  18.  
  19. usr_lbl = tk.Label(login, text='Username:')
  20. usr_lbl.grid(column=0, row=0)
  21.  
  22. usr_entry_var = tk.StringVar()
  23. usr_entry = tk.Entry(login, width=40, textvariable=usr_entry_var)
  24. usr_entry.grid(column=1, row=0)
  25.  
  26. pwd_lbl = tk.Label(login, text='Password:')
  27. pwd_lbl.grid(column=0, row=1)
  28.  
  29. pwd_entry_var = tk.StringVar()
  30. pwd_entry = tk.Entry(login, width=40, textvariable=pwd_entry_var)
  31. pwd_entry.grid(column=1, row=1)
  32.  
  33. ok_btn = tk.Button(login, text='OK', command=click_ok)
  34. ok_btn.grid(column=0, columnspan=2, row=2)
  35.  
  36. def click_run():
  37. connection = log_in()
  38.  
  39. # Here is where I perform actions against the returned connection instance.
  40. # I am just printing it here for brevity.
  41. print(str(connection))
  42.  
  43. root = tk.Tk()
  44.  
  45. run_btn = tk.Button(root, text='RUN', command=click_run)
  46. run_btn.pack()
  47.  
  48. root.mainloop()
Add Comment
Please, Sign In to add comment