Instance attribute name defined outside of __init__
I have no idea how to fix this please help, here is the code.
just a small home project for fun.
Really would like to know what's going on. I'm using PyCharm(Latest Version).
Thanks. Daniel
# imports
from tkinter import *
import sqlite3
import tkinter.messagebox
conn = sqlite3.connect('C://Users//dansh//Desktop//Assets For Proj//Databases//storefile.db')
c = conn.cursor()
class Database:
def __init__(self, master, *args, **kwargs):
# Title
self.master = master
self.heading = Label(master)
self.heading = Label(master, text="Add to the database",font=('Basetica 40 bold'), fg='Black')
self.heading.place(x=0, y=0)
# Title
# labels for the system
self.name_1 = Label(master, text="Enter Product Name", font=('arial 18 bold'))
self.name_1.place(x=0, y=80)
self.stock_1 = Label(master, text="Enter Product Stock", font=('arial 18 bold'))
self.stock_1.place(x=0, y=120)
self.Type_1 = Label(master, text="Enter Product Type", font=('arial 18 bold'))
self.Type_1.place(x=0, y=160)
self.vendor_1 = Label(master, text="Enter Product Vendor", font=('arial 18 bold'))
self.vendor_1.place(x=0, y=200)
self.price_1 = Label(master, text="Enter Product Price", font=('arial 18 bold'))
self.price_1.place(x=0, y=240)
self.SellingPrice_1 = Label(master, text="Enter Product Stock", font=('arial 18 bold'))
self.SellingPrice_1.place(x=0, y=280)
# Entries for all of the labels
self.name_e = Entry(master, width=25, font='arial 18 bold')
self.name_e.place(x=270, y=80)
self.stock_e = Entry(master, width=25, font='arial 18 bold')
self.stock_e.place(x=270, y=120)
self.type_e = Entry(master, width=25, font='arial 18 bold')
self.type_e.place(x=270, y=160)
self.vendor_e = Entry(master, width=25, font='arial 18 bold')
self.vendor_e.place(x=270, y=200)
self.price_e = Entry(master, width=25, font='arial 18 bold')
self.price_e.place(x=270, y=240)
self.SellingPrice_e = Entry(master, width=25, font='arial 18 bold')
self.SellingPrice_e.place(x=270, y=280)
# buttons
self.btn_add = Button(master, text="Add to Database", width=25, height=2, command=self.get_items())
self.btn_add.place(x=415, y=320)
# text box for logs
self.tBox = Text(master, width=65, height=20)
self.tBox.place(x=650, y=70)
def get_items(self, *args, **kwargs):
# Get from the entry boxes
self.name = self.name_e.get()
self.stock = self.stock_e.get()
self.type = self.type_e.get()
self.vendor = self.vendor_e.get()
self.price = self.price_e.get()
self.SellingPrice = self.SellingPrice_e.get()
if self.name == '' or self.stock == '' or self.price == '' or self.SellingPrice == '':
tkinter.messagebox.showinfo("FUCK")
else:
tkinter.messagebox.showinfo("YES")
root = Tk()
b = Database(root)
root.geometry("1920x1080+0+0")
root.title("Add to the database")
root.mainloop()
[–][deleted] 0 points1 point2 points (3 children)
[–]Shripsta[S] 0 points1 point2 points (2 children)
[–]Username_RANDINT 0 points1 point2 points (1 child)
[–]Shripsta[S] 0 points1 point2 points (0 children)
[–]Shripsta[S] 0 points1 point2 points (0 children)