def payment_complete():
    if os.path.exists(inp.database_file(inp.temp_file)):
        payment_label = tk.Label(message_frame,
                                 text="\tThank you for your Payment\t\t").grid(
                                     row=0, column=0)
        with open(inp.database_file(inp.temp_file), 'r') as sel:
            pass_val = sel.readline().rstrip()
            dl.data_entry(pass_val)
        inp.remove_file()
    else:
        payment_label = tk.Label(message_frame,
                                 text="\tSelect your product\t\t").grid(
                                     row=0, column=0)
def payment(value):
    payment_label = tk.Label(message_frame,
                             text="\t\tPayment Due : $ {} \t\t".format(
                                 inp.product_price)).grid(row=0, column=0)
    with open(inp.database_file(inp.temp_file), 'w') as tp:
        csv_writer = csv.writer(tp)
        csv_writer.writerow([value])
def popup():
    popup_window = tk.Tk()
    popup_window.title("Reports")
    popup_window.geometry("200x100")
    label = tk.Label(popup_window, text="Reports Selection")
    label.pack()
    daily_sales_button = tk.Button(
        popup_window,
        text="Daily Sales Report",
        command=lambda: rpt.daily_sales()
        if os.path.exists(inp.database_file(inp.file_name)) else msg()).pack()
    product_sales_button = tk.Button(
        popup_window,
        text="Product Sales Report",
        command=lambda: rpt.product_sales()
        if os.path.exists(inp.database_file(inp.file_name)) else msg()).pack()
    popup_window.mainloop()
示例#4
0
def product_sales():
    df = pd.read_csv(inp.database_file(inp.file_name))
    product_sales = df.groupby(['Product_Name']).Product_Price.count().reset_index()
    product_sales.plot(kind='bar', x='Product_Name', y='Product_Price')
    plt.xlabel("Product Name", labelpad=11)
    plt.ylabel("Product Count", labelpad=11)
    plt.title("Product Sales Count Report", y=1.02)
    plt.legend().set_visible(False)
    plt.show()
def clear_payment():
    if os.path.exists(inp.database_file(inp.temp_file)):
        payment_label = tk.Label(message_frame,
                                 text="\tSelect your product\t\t").grid(
                                     row=0, column=0)
        inp.remove_file()
    else:
        payment_label = tk.Label(message_frame,
                                 text="\tSelect your product\t\t").grid(
                                     row=0, column=0)
示例#6
0
def daily_sales():
    df = pd.read_csv(inp.database_file(inp.file_name))
    daily_sales = df.groupby(['Sales_Date']).Product_Price.sum().reset_index()
    daily_sales.plot(kind='bar', x='Sales_Date', y='Product_Price')
    plt.xlabel("Date", labelpad=11)
    plt.ylabel("Sales Amount", labelpad=11)
    plt.title("Daily Sales Amount Report", y=1.02)
    plt.gcf().subplots_adjust(bottom=0.2)
    plt.legend().set_visible(False)
    plt.show()
def data_entry(item_number):
    if item_number == '1':
        product_name = "Coke"
    elif item_number == '2':
        product_name = "Sprite"
    elif item_number == '3':
        product_name = "Fanta"
    else:
        product_name = "Water"
    if os.path.exists(inp.database_file(inp.file_name)):
        with open(inp.database_file(inp.file_name), 'a') as csv_file:
            csv_writer = csv.writer(csv_file, lineterminator='\n')
            csv_writer.writerow(
                [item_number, product_name, inp.product_price, inp.today_date])
    else:
        with open(inp.database_file(inp.file_name), 'w') as csv_file:
            csv_writer = csv.writer(csv_file, lineterminator='\n')
            csv_writer.writerow(
                ['Product_ID', 'Product_Name', 'Product_Price', 'Sales_Date'])
            csv_writer.writerow(
                [item_number, product_name, inp.product_price, inp.today_date])

# Popup main window
main_window = tk.Tk()
main_window.title("Vending Machine")
main_window.geometry("400x400")

welcome_lbl = tk.Label(
    main_window,
    text="Welcome to \n Vending Machine \n Program \n Today's Date : {}".
    format(inp.today_date),
    font="Verdana 14 bold")
welcome_lbl.pack()

# Selection Image location
coke = tk.PhotoImage(file=inp.database_file(inp.coke)).subsample(2, 2)
sprite = tk.PhotoImage(file=inp.database_file(inp.sprite)).subsample(2, 2)
fanta = tk.PhotoImage(file=inp.database_file(inp.fanta)).subsample(2, 2)
water = tk.PhotoImage(file=inp.database_file(inp.water)).subsample(2, 2)

# selection frame
selection_frame = tk.Frame(main_window)
selection_frame.pack(side=tk.TOP)

# message frame
message_frame = tk.Frame(main_window)
message_frame.pack(side=tk.LEFT)

# payment button frame
payment_frame = tk.Frame(main_window)
payment_frame.pack(side=tk.BOTTOM)