Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Login Interface tutorial
- from tkinter import * #import tkinter module
- from tkinter import messagebox #import messagebox
- tk = Tk()
- tk.title("Login Interface")
- def confirm(): #Confirm function of the button
- username = entrys[0].get()
- password = entrys[1].get()
- accept = variable.get()
- if username == "OrangoMango" and password == "bingo" and accept == 1:
- #we check if username and password are correct
- messagebox.showinfo("Login", "Login correct")
- else:
- messagebox.showerror("Login", "Login incorrect")
- entrys = [] #list of text areas
- labelstext = ["Enter username:", "Enter password:"]
- for x in range(2):
- l = Label(tk, text=labelstext[x]) #Label with the text of the list
- l.grid(column=0, row=x) #We put the label in a grid layout
- e = Entry(tk, show="" if x == 0 else "*") #we show the normal characters if we need to input the username, the password is shown with *
- e.grid(column=1, row=x)
- entrys.append(e) #We add the entry to the list
- variable = IntVar() #we create a tkinter variable
- #If the checkbutton is active variable = 1, else variable = 0
- c = Checkbutton(tk, text="Accept therms of privacy", variable=variable, onvalue=1, offvalue=0) #we create a checkbutton
- c.grid(column=0, row=2, columnspan=2)
- b = Button(tk, text="Confirm", command=confirm) #We create a button
- #with the confirm text and the confirm function
- b.grid(column=1, row=3, sticky="e")
- tk.mainloop()
Add Comment
Please, Sign In to add comment