Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
2.6 kB
5
Indexable
Never
import tkinter as tk
from tkinter import *
from datetime import date


class App(tk.Tk):
    def __init__(self):
        super().__init__()

        # configuration
        self.title('M E N U')
        self.geometry('750x500')

        # label
        self.label_main = Label(self, text="Farido's Restaurant Menu", font = ('calibiri',20,'bold'))
        self.label_main.grid(column=0, row=1, columnspan=500)

        self.label_client_num  = Label(self, text = "Client Nu  ")
        self.label_client_num.grid(column=4, row=7)

        self.label_date = Label(self, text = "Date  ")
        self.label_date.grid(column=17, row=7)

        #entry + vars
        self.client_entry_var = StringVar()
        self.client_entry = Entry(self, bd = 1, textvariable = self.client_entry_var)
        self.client_entry.grid(column=8, row=7)

        self.date_entry_var = StringVar()
        self.date_entry = Entry(self, bd=1, textvariable=self.date_entry_var)
        self.date_entry.grid(column=19, row=7)
        self.today = date.today()
        self.frmt = self.today.strftime("%Y/%m/%d")
        for self.test in self.frmt:
            self.date_entry_var.set(self.frmt)
            self.date_entry.config(state = 'disable')

        # table
        for i in range(total_rows):
            for j in range(total_columns):
                self.e = Entry(self, width=15,
                               font=('calibiri', 10))
                self.e.grid(row=i*12, column=j*12, columnspan = 10)
                self.e.insert(END, lst[i][j])



        # button
        self.clear = Button(self, text='Clear')
        #self.button['command'] = self.function
        self.clear.grid(column = 2, row = 10)

        self.calculate = Button(self, text = "Calculate")
        self.calculate['command'] = self.calculation
        self.calculate.grid(column = 4, row = 10)

        self.save = Button(self, text="Save")
        # self.button['command'] = self.function
        self.save.grid(column=10, row=1000)

    def calculation(self,lst):
        for tup in lst[1:]:
            if tup[2] > 0:
                print(tup[1] * tup[2])



lst = [('Description', 'Price', 'Qtty', 'Amount'),
       ('Kafta'   , 30, 0, 0),
       ('Shawarma', 35, 0, 0),
       ('Tabouleg', 15, 0, 0),
       ('Steak'   , 50, 0, 0),
       ('Shrimp'  , 40, 0, 0),
       ('Other'   , 0, 0, 0)]

# find total number of rows and
# columns in list
total_rows = len(lst)
total_columns = len(lst[0])


if __name__ == "__main__":
    app = App()
    app.mainloop()