Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- class Application(Frame):
- def __init__(self,master):
- Frame.__init__(self,master)
- self.grid()
- self.create_widgets()
- def create_widgets(self):
- self.instruction = Label(self,text='Enter your Username')
- self.instruction.grid(row=0, column=0, columnspan=2,sticky=W)
- self.username=Entry(self)
- self.username.grid(row=1, column =1, sticky=W)
- self.sumbit_button=Button(self,text='Submit',command= self.reveal)
- self.sumbit_button.grid(row=5,column=0,sticky=W)
- self.instruction = Label(self,text='Enter a password')
- self.instruction.grid(row=3, column=0, columnspan=2,sticky=W)
- self.password=Entry(self)
- self.password.grid(row=4, column =1, sticky=W)
- self.text = Text(self,width=35, height=5, wrap=WORD)
- self.text.grid(row=6, column=0, columnspan=2,sticky=W)
- def reveal(self):
- file=open('data.RTF','r')
- data1=file.readlines()
- file.close
- content2=self.username.get()
- content=self.password.get()
- if content2==(data1[0]) and content==(data1[1]):
- message='You have access to something special.'
- else:
- message='Access denied.'
- self.text.delete(0.0,END)
- self.text.insert(0.0,message)
- root=Tk()
- root.title('Username and Password')
- root.geometry('250x150')
- app=Application(root)
- root.mainloop()
Add Comment
Please, Sign In to add comment