first commit
This commit is contained in:
80
main.py
Normal file
80
main.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import time
|
||||||
|
import pickle
|
||||||
|
import tkinter as tk
|
||||||
|
import easygui
|
||||||
|
|
||||||
|
class dependencyrequirement():
|
||||||
|
def __init__(self, name: str,amount: list):
|
||||||
|
self.name = name
|
||||||
|
self.amount = amount
|
||||||
|
class product():
|
||||||
|
def __init__(self, name: str,price: float,dependencies: list):
|
||||||
|
self.name = name
|
||||||
|
self.price = price
|
||||||
|
self.dependencies = dependencies
|
||||||
|
class database():
|
||||||
|
def __init__(self):
|
||||||
|
self.dependencies = []
|
||||||
|
self.products = {}
|
||||||
|
self.stock = {}
|
||||||
|
pass
|
||||||
|
def adddep(self, name: str):
|
||||||
|
self.dependencies.append(name)
|
||||||
|
self.stock[name] = 0.0
|
||||||
|
def addproduct(self, name: str, price: float, dependencies: list):
|
||||||
|
self.products[name] = product(name,price,dependencies)
|
||||||
|
def processproduct(self, name: str):
|
||||||
|
product = self.products[name]
|
||||||
|
# add changes to stock
|
||||||
|
for i in product.dependencies:
|
||||||
|
self.stock[i.name] -= i.amount
|
||||||
|
|
||||||
|
maindata = database()
|
||||||
|
|
||||||
|
def clear():
|
||||||
|
for i in range(100):
|
||||||
|
print()
|
||||||
|
def products_new(root):
|
||||||
|
childwin = tk.Toplevel(root)
|
||||||
|
childwin.title("New product")
|
||||||
|
|
||||||
|
namevar = tk.StringVar(value="Name")
|
||||||
|
nameinp = tk.Entry(childwin, textvariable=namevar)
|
||||||
|
nameinp.grid(row=0,column=0)
|
||||||
|
|
||||||
|
pricevar = tk.StringVar(value="Price")
|
||||||
|
priceinp = tk.Entry(childwin, textvariable=pricevar)
|
||||||
|
priceinp.grid(row=1,column=0)
|
||||||
|
|
||||||
|
dependencies = tk.Listbox(childwin, selectmode=tk.SINGLE, height=len(maindata.dependencies), width=50)
|
||||||
|
dependencies.grid(row=2,column=0)
|
||||||
|
|
||||||
|
def close():
|
||||||
|
childwin.destroy() # destroy so incase of an fail we still are finished.
|
||||||
|
maindata.addproduct(namevar.get(), float(pricevar.get()), [])
|
||||||
|
|
||||||
|
addbut = tk.Button(childwin, text="Create", command=close)
|
||||||
|
addbut.grid(row=10,column=0)
|
||||||
|
|
||||||
|
childwin.mainloop()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
easygui.msgbox("Welcome to CashierSystem PC edition!", "Welcome")
|
||||||
|
root = tk.Tk() # root
|
||||||
|
|
||||||
|
menubar = tk.Menu(root) # menubar
|
||||||
|
root.config(menu=menubar)
|
||||||
|
|
||||||
|
promenu = tk.Menu(menubar) # product menu
|
||||||
|
promenu.add_command(
|
||||||
|
label='new',
|
||||||
|
command=lambda: products_new(root),
|
||||||
|
)
|
||||||
|
menubar.add_cascade(
|
||||||
|
label="Products",
|
||||||
|
menu=promenu,
|
||||||
|
underline=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
easygui
|
||||||
Reference in New Issue
Block a user