Advertisement
Guest User

Untitled

a guest
Dec 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox
  3.  
  4.  
  5. #tkinter~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. #the username and password
  7. Username='None'
  8. Password='None'
  9. ValidUser=False
  10.  
  11. def LoginWindow(sort):
  12. Tpassword='1234'
  13. Epassword='4321'
  14.  
  15. def show_entry_fields():
  16. global Username,Password,ValidUser
  17. User=e1.get()
  18. Pass=e2.get()
  19. if sort == 'T':
  20. if Pass!=Tpassword:
  21. tkinter.messagebox.showinfo("Warning","Bad Password!")
  22. ValidUser=False
  23.  
  24. else:
  25. Username,Password=User,Pass
  26. ValidUser=True
  27. window.destroy()
  28. elif sort == 'E':
  29. if Pass!=Epassword:
  30. tkinter.messagebox.showinfo("Warning","Bad Password!")
  31. ValidUser=False
  32.  
  33. else:
  34. Username,Password=User,Pass
  35. ValidUser=True
  36. window.destroy()
  37.  
  38. window = Tk()
  39. window.title("Login") #title
  40.  
  41. #window.minsize(width=200,height=0) #force window size if needed
  42. #size and location of window
  43. #size
  44. w = 200 # width for the window
  45. h = 80 # height for the window
  46. #location
  47. '''
  48. #side position
  49. #x = 625
  50. #y = 120
  51. '''
  52. x=400
  53. y=300
  54.  
  55. # set the dimensions of the screen
  56. # and where it is placed
  57. window.geometry('%dx%d+%d+%d' % (w, h, x, y))
  58.  
  59.  
  60. Label(window, text="User Name").grid(row=0)
  61. Label(window, text="Password").grid(row=1)
  62.  
  63. e1 = Entry(window)
  64. e2 = Entry(window)
  65.  
  66. e1.grid(row=0, column=1)
  67. e2.grid(row=1, column=1)
  68.  
  69. Button(window, text='Back', command=window.destroy).grid(row=3, column=0, sticky=W, pady=4)
  70. Button(window, text='Login', command=show_entry_fields).grid(row=3, column=1, sticky=W, pady=4)
  71. window.call('wm', 'attributes', '.', '-topmost', '1') #make the window on top of pygame window
  72.  
  73. mainloop()
  74. #-----------------------------------------
  75. #end of tkinter window
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement