I must be missing something but I just cant find it here's my code
CODE
#Longevity
#Demonstrates text entry widget and the grid layout manager
from Tkinter import *
class Application(Frame):
def __init__(self,master):
Frame.__init__(self,master)
self.grid()
self.create_widgets()
def create_widgets(self):
#Instruction label
self.inst_lbl = Label(self, text = "Enter password for the secret to longevity").grid(row = 0, column = 0, columnspan = 2, sticky = W)
#Password label
self.pwd_lbl = Label(self, text = "Password: ").grid(row = 1, column = 0, sticky = W)
#Entry widget
self.pw_ent = Entry(self).grid(row = 1, column = 1, sticky = W)
#Submit button
self.submit_bttn = Button(self, text = "Submit", command = self.reveal).grid(row = 2, column = 0, sticky = W)
#Text box
self.secret_txt = Text(self, width = 35, height = 5, wrap =WORD).grid(row = 3, column = 0, columnspan = 2, sticky = W)
def reveal(self):
contents = self.pw_ent.get() #This is where I get the error
if contents == "secret":
message = "Live to 99 then be really careful"
else:
message = "Incorrect password"
self.secret_txt.delete(0.0,END)
self.secret_txt.insert(0.0,message)
#main
root = Tk()
root.title("Longevity")
root.geometry("250x150")
app = Application(root)
root.mainloop()
this is the error I am getting
CODE
File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1406, in __call__
return self.func(*args)
File "/home/chaos/none", line 27, in reveal
contente = self.pw_ent.get()
AttributeError: 'NoneType' object has no attribute 'get'
WTF am I doing wrong?
This post has been edited by itpro4470: 3 Aug, 2008 - 10:12 PM