I have searched quite a bit,but I couldn't find a solution to this. I'm trying to create a registration form using tkinter which later on i shall connect to a database. Here is the code :
from Tkinter import *
class MWindow(object):
def __init__(self,master):
self.frame=Frame(master)
self.frame.pack()
self.title= Label(self,text = "Login")
self.title.grid(row=0,column=1)
self.userid_label = Label(self,text ="Username: ")
self.userid_label.grid(row=1,column=0)
self.userid_entry= Entry(self)
self.userid_entry.grid(row=1,column=1)
self.password_label = Label(self,text ="Password: ")
self.password_label.grid(row=2,column=0)
self.password_entry= Entry(self)
self.password_entry.grid(row=2,column=1)
self.signin = Button (self,text = "Login",command=logging_in)
self.signin.grid(row=5,column=1)
self.signup = Button (self,text = "Sign Up",command=signing_up)
self.signin.grid(row=5,column=2)
def logging_in(self):
pass
def signing_up(self):
pass
root= Tk()
root.attributes('-fullscreen',True)
root.resizable(width=False, height=False)
root.title("My Registration Form")
app=MWindow(root)
root.mainloop()
Here is the error i get :
Traceback (most recent call last):
File "form.py", line 41, in
app=MWindow(root)
File "form.py", line 11, in init
self.title= Label(self,text = "Login")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2591, in init
Widget.init(self, master, 'label', cnf, kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2081, in init
BaseWidget._setup(self, master, cnf)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2059, in _setup
self.tk = master.tk
AttributeError: 'MWindow' object has no attribute 'tk'
I tried going to the library files to understand what's wrong,but being a beginner i can't make much of it. Some explanation of what's going wrong and why would be very helpful.