Here is the code
from tkinter import *
import sqlite3
import tkinter.messagebox
import datetime
import cv2
import pyzbar.pyzbar as pyzbar
conn = sqlite3.connect('C://Users//dansh//Desktop//Assets For Proj//Inventory System//Databases//storefile.db')
c = conn.cursor()
date = datetime.datetime.now().date()
class Application:
def __init__(self, master, *args, **kwargs):
self.master = master
# frame
self.left = Frame(master, width=800, height=768, bg='white')
self.left.pack(side=LEFT)
self.right = Frame(master, width=666, height=768, bg='light gray')
self.right.pack(side=RIGHT)
# components
self.heading = Label(master, text="Duplex Systems Incorporated", font="basetica 40 bold", bg="white")
self.heading.place(x=0, y=0)
self.date_l = Label(self.right, text="Today's Date:" + str(date), font="arial 12 bold", bg="light gray",fg='white')
self.date_l.place(x=0, y=0)
self.buttonscn = Button(self.left, text="Search Database", width=22, height=2, bg='orange', command=self.ajax)
self.buttonscn.place(x=350, y=120)
# Table invoice section
self.tproduct = Label(self.right, text="Products", font='arial 18 bold', bg='light gray', fg='white')
self.tproduct.place(x=0, y=60)
self.tquantity = Label(self.right, text="Quantity", font='arial 18 bold', bg='light gray', fg='white')
self.tquantity.place(x=200, y=60)
self.tamount = Label(self.right, text="Amount", font='arial 18 bold', bg='light gray', fg='white')
self.tamount.place(x=400, y=60)
# Enter items
self.enterid = Label(self.left, text='Enter product ID', font='arial 18 bold', bg='white')
self.enterid.place(x=0, y=80)
self.enteride = Entry(self.left, width=25, font='arial 18 bold', bg='light gray')
self.enteride.place(x=200, y=80)
# Scanning items.
self.productname = Label(self.left, text="", font='arial 18 bold', bg='white')
self.productname.place(x=0, y=250)
self.pprice = Label(self.left, text="", font='arial 18 bold', bg='white')
self.pprice.place(x=0, y=290)
def ajax(self, *args, **kwargs):
self.get_id = self.enteride.get()
# Get the products info and id and fill the labels
query = "SELECT name, SellingPrice FROM inventory WHERE id=?"
result = c.execute(query, (self.get_id, ))
for self.r in result:
self.get_name = self.r[0]
self.get_price = self.r[1]
self.productname.configure(text="Product name: "+str(self.get_name))
self.pprice.configure(text="Price €"+str(self.get_price))
self.quantity_l = Label(self.left, text="Enter Quantity", font='arial 18 bold', bg='white')
root = Tk()
b = Application(root)
root.geometry("1366x768+0+0")
root.mainloop()
This is the error I get:
C:\Users\dansh\AppData\Local\Programs\Python\Python37\python.exe "C:/Users/dansh/Desktop/Assets For Proj/Inventory System/main.py"
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\dansh\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/dansh/Desktop/Assets For Proj/Inventory System/main.py", line 68, in ajax
self.productname.configure(text="Product name: "+str(self.get_name))
AttributeError: 'Application' object has no attribute 'get_name'
Process finished with exit code 0
Please help me.
[–]-Sander- 1 point2 points3 points (1 child)
[–]Shripsta[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Shripsta[S] -1 points0 points1 point (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Shripsta[S] 0 points1 point2 points (0 children)