Advertisement
Guest User

Login took

a guest
Apr 2nd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #import the 'tkinter' module
  2. import tkinter
  3. #sets variable secs to be used in countdown
  4. sec=5
  5. #definding func that checks pass and username and if correct opens window
  6. def newWin():
  7. #getting pass and username
  8. password=entPassword.get()
  9. username=entUsername.get()
  10. if username=='user' and password=='pass': #if username and password is correct run this
  11. #creats a new window with black background
  12. win=tkinter.Tk()
  13. win.configure(background='black')
  14. #creates a label
  15. lbl=tkinter.Label(win,text="We are Anonymous\n We are Legion\n We do not Forgive\n We do not Forget.",fg='red',bg='black',font=("comic sans ms", 32))
  16. lbl.pack()
  17. win.after(5000,win.destroy) #close window after 5 seconds, 5000 miliseconds=5 seconds
  18. else: #if username or password is wrong run this
  19. root = tkinter.Tk() #opens up new window with message
  20. lbl=tkinter.Label(root,text='This Device will now destruct in...', fg='red',bg='black', font=('Helvetica',32))
  21. lbl.pack()
  22. root.configure(bg='black')
  23. #sets a label with no text
  24. time = tkinter.Label(root, fg='red',bg='black',font=('Helvetica',32))
  25. time.pack()
  26. #adds text to the lable
  27. #this is a countdown timer
  28. def tick():
  29. #calls on the variable sec
  30. global sec
  31. #sets sec as the text for the empty label
  32. time['text']=sec
  33. sec-=1
  34. #if sec is larger than negative one run this function again (removes 1 from sec and sets as new text value)
  35. if sec>-1:
  36. #only runs even 1000 milliseconds (1 second)
  37. time.after(1000,tick)
  38. else: #once sec has passed 0 run this
  39. #closes countdown window
  40. root.destroy()
  41. #closes main window
  42. window.destroy()
  43. #starts the countdown
  44. tick()
  45. root.mainloop()
  46. #create a new window
  47. window = tkinter.Tk()
  48. #set the window background to hex code '#a1dbcd'
  49. window.configure(background="#a1dbcd")
  50. #set the window title
  51. window.title("Welcome")
  52. #set the window icon
  53. window.wm_iconbitmap('C:\My Stuff\Misc\icon.ico')#must be a .ico file
  54.  
  55. photo = tkinter.PhotoImage(file="C:\My Stuff\Misc\dog.png")
  56. w = tkinter.Label(window, image=photo)
  57. w.pack()
  58.  
  59. #create a label for the instructions
  60. lblInst = tkinter.Label(window, text="Please login to continue:", fg="#383a39", bg="#a1dbcd", font=("Helvetica", 16))
  61. #and pack it into the window
  62. lblInst.pack()
  63.  
  64. #create the widgets for entering a username
  65. lblUsername = tkinter.Label(window, text="Username:", fg="#383a39", bg="#a1dbcd")
  66. entUsername = tkinter.Entry(window)
  67. #and pack them into the window
  68. lblUsername.pack()
  69. entUsername.pack()
  70.  
  71. #create the widgets for entering a username
  72. lblPassword = tkinter.Label(window, text="Password:", fg="#383a39", bg="#a1dbcd")
  73. entPassword = tkinter.Entry(window)
  74. #and pack them into to the window
  75. lblPassword.pack()
  76. entPassword.pack()
  77.  
  78. #create a button widget called btn
  79. btn = tkinter.Button(window, text="Login", fg="#a1dbcd", bg="#383a39",command=newWin)
  80. #pack the widget into the window
  81. btn.pack()
  82.  
  83. #draw the window, and start the 'application'
  84. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement