def show_item_tree(self): """show menu to order foods""" self.item_tree.delete(*self.item_tree.get_children()) item = Item() data = item.show_items() for i in data: self.item_tree.insert("", "end", text=i[0], value=(i[0], i[2], i[1], i[3]))
def show_item_tree(self): """display menu""" self.item_tree.delete(*self.item_tree.get_children()) item = Item() data = item.show_items() for i in data: self.item_tree.insert("", "end", text=i[0], value=(i[2], i[1], i[3])) self.item_tree.bind("<Double-1>", self.select_item)
def ser_item(self): """search for food item to order""" search = self.item_ser.get() self.item_tree.delete(*self.item_tree.get_children()) item = Item() data = item.search_item(search) for i in data: self.item_tree.insert("", "end", text=i[0], value=(i[0], i[2], i[1], i[3]))
def ser_item(self): """search for item in menu""" search = self.item_ser.get() self.item_tree.delete(*self.item_tree.get_children()) item = Item() data = item.search_item(search) for i in data: self.item_tree.insert("", "end", text=i[0], value=(i[2], i[1], i[3])) self.item_tree.bind("<Double-1>", self.select_item)
def del_item(self): """delete an item from menu""" item = Item() a = messagebox.askyesno("Delete", "Are you sure you want to delete this item?") if a == 1: if item.delete_item(self.item_index): messagebox.showinfo("Item", "Item Deleted") self.show_item_tree() self.reset_btn() else: messagebox.showerror("Error", "Item cannot be deleted")
def update_item(self): """update an item detail in menu""" name = self.item_name.get() type_ = self.item_type.get() price = self.item_rate.get() id_ = self.item_index item = Item() if item.update_item(id_, name, type_, price): messagebox.showinfo("Item", "Item Updated") self.show_item_tree() self.reset_btn() else: messagebox.showerror("Error", "Item cannot be added")
def add_item(self): """verify the entry values and add new item to menu""" name = self.item_name.get() type_ = self.item_type.get() price = self.item_rate.get() item = Item() if name == "" or price == "": messagebox.showerror("Error", "Enter all values") elif not price.isnumeric(): messagebox.showerror("Error", "Enter numeric value for price") else: if item.add_item(name, type_, price): messagebox.showinfo("Item", "Item Added") self.show_item_tree() self.reset_btn() else: messagebox.showerror("Error", "Item cannot be added")