I'm sure it is a simple mistake and I've localized it to a specific spot in the code:
class NewProduct(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
tLabel = ttk.Label(self, text="Title: ", font=NORM_FONT).grid(row=0, padx=5, pady=5)
qLabel = ttk.Label(self, text="Quantity: ", font=NORM_FONT).grid(row=1, padx=5, pady=5)
pLabel = ttk.Label(self, text="Price: $", font=NORM_FONT).grid(row=2, padx=5, pady=5)
te = ttk.Entry(self).grid(row=0, column=1, padx=5, pady=5) # Add validation in the future
qe = ttk.Entry(self).grid(row=1, column=1, padx=5, pady=5)
pe = ttk.Entry(self).grid(row=2, column=1, padx=5, pady=5)
saveButton = ttk.Button(self, text="Save", command=lambda: self.save(self.te.get(), self.qe.get(), self.pe.get()))
#WHY IS THIS WRONG!!!!!???!?!?!?!?!?
saveButton.grid(row=4, padx=5)
cancelButton = ttk.Button(self, text="Cancel", command=lambda: popupmsg("Not functioning yet."))
cancelButton.grid(row=4, column=1, padx=5)
def save(self, title, quantity, price):
conn = sqlite3.connect("ComicEnv.db")
c = conn.cursor()
c.execute("INSERT INTO cdata(unix, datestamp, title, quantity, price) VALUES (?,?,?,?,?)",
(time.time(), date, title, quantity, price))
conn.commit()
conn.close()
I've tried a few different things including:
saveButton = ttk.Button(self, text="Save", command=lambda: self.save(te.get(), qe.get(), pe.get()))
I'm trying to get the user input from the entry widget and store it in a sqlite3 database.
This is the Traceback:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "C:\Users\aedwards\Desktop\deleteme.py", line 106, in <lambda>
saveButton = ttk.Button(self, text="Save", command=lambda: self.save(self.te.get(), self.qe.get(), self.pe.get()))
AttributeError: 'NewProduct' object has no attribute 'te'
Any help you guys could give me would be greatly appreciated. Any more information, please just let me know.
Thanks in advance!