def modify_item(self, parent, item): try: new_name = self.name_entry.get_text() new_price = float (self.price_entry.get_text()) new_quantity = float(self.quantity_entry.get_text()) new_plu_number = float(self.plu_number_entry.get_text()) new_item_type = self.item_type_entry.get_text() new_category = self.item_type_category_entry.get_text() new_item = Item(new_name, new_price, new_quantity, new_plu_number, new_item_type, new_category) if check_if_new_item_is_correct(new_item) == True: item.update(new_item) store_items(parent.list_of_items) parent.render_form() else: dialog = alert_messagebox("Error, the fields have been incorrectly filled out") response = dialog.run() dialog.destroy() except: alert_messagebox("Error, the items have been incorrectly formated") clear_list_box(parent) self.destroy()
def clear_basket_handler(button_event, self): if len(self.current_basket) == 0: alert_messagebox("Sorry, your basket is empty") # window.show_all() else: clear_list_box(self) self.current_basket.clear() self.render_form()
def checkout_handler(button_event, self): if self.sign_on: checkout(self.current_basket) # new_purchase = Purchase(current_basket, self.staff_member, self.staff_member) clear_list_box(self) self.current_basket.clear() else: alert_messagebox("You are not signed on yet")
def check_code_is_correct(self, staff_member, entered_code): self.staff_member = staff_member self.sign_on_screen.destroy() if staff_member.passcode == entered_code: self.sign_on = True self.current_user = staff_member print("User: "******" has signed on") else: alert_messagebox("The passcode you have entered is incorrect")
def add_to_total(button, self, item): if self.sign_on: self.current_basket.append(item) self.total = self.total + item.price total_details = "£" + "{:.2f}".format(self.total) item_details = str(item.price) + " " + item.name add_to_list_box(self, item_details, total_details) else: alert_messagebox("You are not signed on yet")
def modify_staff_member(self, old_staff, parent): new_passcode = self.passcode_entry.get_text() new_gender = self.gender_entry.get_text() new_employee_type = self.employee_type_entry.get_text() if check_if_string_is_valid(new_passcode, new_gender, new_employee_type): old_staff.update_details(new_passcode, new_gender, new_employee_type) store_staff(parent.list_of_staff) self.destroy() else: dialog = alert_messagebox("Error, all fields must be filled in") response = dialog.run() dialog.destroy()
def run_checkout_window(checkout_text): alert_messagebox(checkout_text)