Advertisement
Guest User

Untitled

a guest
Jul 5th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. from Tkinter import *
  2. from win32api import GetSystemMetrics
  3. from pymongo import MongoClient
  4. import main
  5.  
  6. def login_click():
  7. users_db = MongoClient()["market_natya"]["users"]
  8. username = login_username_entry.get()
  9. password = login_password_entry.get()
  10. if (users_db.find({"user_name": username}).count() > 0) and (users_db.find({"password": password}).count() > 0):
  11. login_form.destroy()
  12. main.main_forms(username)
  13. else:
  14. login_label["text"] = "Acces denided!"
  15. pass
  16.  
  17. def login_exit():
  18. login_form.destroy()
  19.  
  20. login_form = Tk()
  21. login_form.title("Login")
  22. login_form.geometry(
  23. "400x200+" + str((int(GetSystemMetrics(0)) / 2) - 200) + "+" + str((int(GetSystemMetrics(1)) / 2) - 100))
  24. login_form.resizable(False, False)
  25.  
  26. login_username_entry = Entry(login_form)
  27. login_username_entry.place(width=300, height=25, anchor="center", x=240, y=20)
  28. username = login_username_entry.get()
  29.  
  30. login_password_entry = Entry(login_form, show="*")
  31. login_password_entry.place(width=300, height=25, anchor="center", x=240, y=60)
  32. password = login_password_entry.get()
  33.  
  34. login_label_u = Label(login_form)
  35. login_label_u.place(width=100, height=25, anchor="center", x=40, y=20)
  36. login_label_u["text"] = "User name:"
  37.  
  38. login_label_p = Label(login_form)
  39. login_label_p.place(width=100, height=25, anchor="center", x=40, y=60)
  40. login_label_p["text"] = "Password:"
  41.  
  42. login_label = Label(login_form)
  43. login_label.place(width=100, height=25, anchor="center", x=200, y=100)
  44. login_label["text"] = "Wellcome!"
  45.  
  46. login_button = Button(login_form, text="Login", command=login_click)
  47. login_button.place(width=60, height=25, anchor="center", x=100, y=180)
  48.  
  49. login_cancel = Button(login_form, text="Cancel", command=login_exit)
  50. login_cancel.place(width=60, height=25, anchor="center", x=300, y=180)
  51.  
  52. login_form.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement