Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import the 'tkinter' module
- import tkinter
- #sets variable secs to be used in countdown
- sec=5
- #definding func that checks pass and username and if correct opens window
- def newWin():
- #getting pass and username
- password=entPassword.get()
- username=entUsername.get()
- if username=='user' and password=='pass': #if username and password is correct run this
- #creats a new window with black background
- win=tkinter.Tk()
- win.configure(background='black')
- #creates a label
- 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))
- lbl.pack()
- win.after(5000,win.destroy) #close window after 5 seconds, 5000 miliseconds=5 seconds
- else: #if username or password is wrong run this
- root = tkinter.Tk() #opens up new window with message
- lbl=tkinter.Label(root,text='This Device will now destruct in...', fg='red',bg='black', font=('Helvetica',32))
- lbl.pack()
- root.configure(bg='black')
- #sets a label with no text
- time = tkinter.Label(root, fg='red',bg='black',font=('Helvetica',32))
- time.pack()
- #adds text to the lable
- #this is a countdown timer
- def tick():
- #calls on the variable sec
- global sec
- #sets sec as the text for the empty label
- time['text']=sec
- sec-=1
- #if sec is larger than negative one run this function again (removes 1 from sec and sets as new text value)
- if sec>-1:
- #only runs even 1000 milliseconds (1 second)
- time.after(1000,tick)
- else: #once sec has passed 0 run this
- #closes countdown window
- root.destroy()
- #closes main window
- window.destroy()
- #starts the countdown
- tick()
- root.mainloop()
- #create a new window
- window = tkinter.Tk()
- #set the window background to hex code '#a1dbcd'
- window.configure(background="#a1dbcd")
- #set the window title
- window.title("Welcome")
- #set the window icon
- window.wm_iconbitmap('C:\My Stuff\Misc\icon.ico')#must be a .ico file
- photo = tkinter.PhotoImage(file="C:\My Stuff\Misc\dog.png")
- w = tkinter.Label(window, image=photo)
- w.pack()
- #create a label for the instructions
- lblInst = tkinter.Label(window, text="Please login to continue:", fg="#383a39", bg="#a1dbcd", font=("Helvetica", 16))
- #and pack it into the window
- lblInst.pack()
- #create the widgets for entering a username
- lblUsername = tkinter.Label(window, text="Username:", fg="#383a39", bg="#a1dbcd")
- entUsername = tkinter.Entry(window)
- #and pack them into the window
- lblUsername.pack()
- entUsername.pack()
- #create the widgets for entering a username
- lblPassword = tkinter.Label(window, text="Password:", fg="#383a39", bg="#a1dbcd")
- entPassword = tkinter.Entry(window)
- #and pack them into to the window
- lblPassword.pack()
- entPassword.pack()
- #create a button widget called btn
- btn = tkinter.Button(window, text="Login", fg="#a1dbcd", bg="#383a39",command=newWin)
- #pack the widget into the window
- btn.pack()
- #draw the window, and start the 'application'
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement