def submit_weight(weight_submitted): # Method called when weight submitted global productInfo productInfo[2] = weight_submitted # Update tracker with weight helper.get_container().show_frame( ConfirmAdditionFrame.__name__) # Show confirmation page helper.get_container().get_frame(ConfirmAdditionFrame.__name__).set_row( create_row()) # Update GUI row to show selection
def remove_item(batch_number): # Called when asked to remove item result = global_var.database.remove_item(batch_number) # Remove item from db if result: # If success helper.get_container().show_frame(SuccessRemoveFrame.__name__) container = helper.get_container().get_frame(SuccessRemoveFrame.__name__).get_container() # Show success frame tk.Label(container, text=helper.format_batch(batch_number), font=global_var.FONT_HUGE).pack() # Add label with product number else: raise (Exception("Unable to complete database operation")) # If failed raise Exception
def button_main_call(index): # Method called when main meat type selected global productInfo productInfo[0] = meats[index] # Update tracker if (len(productInfo[0][1])) != 0: helper.get_container().show_frame( ButtonSecondFrame.__name__ ) # If meat has sub meat go to sub meat page else: helper.get_container().show_frame( WeightFrame.__name__) # Else go to enter weight page
def __init__(self, master=None): super().__init__(master) self.add_button_to_frame(helper.get_container().go_up, global_var.images["back"]) # Back button self.add_button_to_frame(helper.get_container().go_home, global_var.images["home"]) # Home button self.add_button_to_frame( lambda: helper.get_container().show_frame( frame_name=frames.mainframes.TurnOffFrame.__name__), global_var.images["power"])
def __init__(self, master=None): super().__init__(master) self.previousFrame = self.__class__.__name__ self.add_button_to_frame(text="Add new item", command=lambda: helper.get_container().show_frame( frames.additem.ButtonMainFrame.__name__), image=global_var.images["add"], spacer=False) # Add item button self.add_button_to_frame(text="Remove item", command=lambda: helper.get_container().show_frame( frames.removeitem.RemoveItemFrame.__name__), image=global_var.images["remove"]) # Remove item button self.add_button_to_frame(text="View database", image=global_var.images["eye"], command=helper.view_in_excel) # View in excel button
def __init__(self, master=None): super().__init__(master, title="Add the following item to freezer?", command_no=helper.get_container().go_home, command_yes=add_product) self.previousFrame = WeightFrame.__name__ self.rowFrame = None # Frame where the data is displayed
def submit_batch_number(number): global idNumber idNumber = number row = global_var.database.get_info(number) # Get row object for batch number if row == global_var.ERROR_NO_SUCH_ITEM: helper.get_container().show_frame(NoItemFrame.__name__) # If no such row show no item frame elif row == global_var.ERROR_ITEM_REMOVED: helper.get_container().show_frame(AlreadyRemovedFrame.__name__) # If row already removed show frame else: helper.get_container().show_frame(ItemInfoFrame.__name__) # Else show confirm frame helper.get_container().get_frame(ItemInfoFrame.__name__).set_row(row) # And display data
def add_product(): # Method called when confirmed object removal # Add product to database if productInfo[1] is None: batch_id = global_var.database.add_item( backend.Row(category=productInfo[0][0], weight=productInfo[2])) # If product has no sub type else: batch_id = global_var.database.add_item( backend.Row(category=productInfo[0][0], subcategory=productInfo[1], weight=productInfo[2])) # If product has sub type if batch_id == -1: raise Exception("Could not add to database") helper.get_container().show_frame( SuccessMessage.__name__) # Show success frame container = helper.get_container().get_frame( SuccessMessage.__name__).get_container() # Container for batch number tk.Label(container, text=helper.format_batch(batch_id), font=global_var.FONT_HUGE).pack() # Add batch number to container
def button_second_call(index): # Method called when sub meat type selected global productInfo productInfo[1] = productInfo[0][1][index] # Update tracker helper.get_container().show_frame( WeightFrame.__name__) # Go to weight page
def __init__(self, master=None): super().__init__(master, title="Remove the following item", command_no=helper.get_container().go_home, command_yes=lambda: remove_item(idNumber)) self.previousFrame = RemoveItemFrame.__name__ self.rowFrame = None
def __init__(self, master): super().__init__(master, title="Are you sure you want to quit?", command_yes=helper.turn_off, command_no=helper.get_container().go_up)