class Fridge(object):
    def __init__(self):
        """
        Initializes an empty item list.
        """
        self.item_list = []

    def add_item(self, item_to_add):
        """
        Adds a FridgeItem to this Fridge's item_list.
        """
        self.item_list.append(item_to_add)

    def remove_item_by_index(
        self, index_of_item_to_remove
    ):  #when browsing through the item list, the browser will know what index is selected, and pass that to this.
        """
        Removes the FridgeItem at this index within the Fridge's item_list
        """
        self.item_list.pop(index_of_item_to_remove)

    def modify_item_by_index(
        self, index_of_item_to_modify, modified_item
    ):  #when browsing through the item list, the browser will know what index is selected, and pass that to this.
        """
        Modifies the FridgeItem at this index by replacing it with a new FridgeItem with the new information.
        """
        self.item_list[index_of_item_to_modify] = modified_item

    def _testcases(self):
        """
        Test cases for the Fridge. Don't call this.
        """
        item = FridgeItem("xd")
        print(item.name)
        #testing item instantiation

        for i in range(1, 10):  #testing field_trimmer
            item.quantity = i + 1
            print(item._quantity)

        for i in range(1, 10):  #testing if -= works with the @property getter
            item.quantity -= 1
            print(item._quantity)
        #continue with testing here..

    if __name__ == '__main__':
        from Fridge import Fridge
        fridge = Fridge()

        #comment this out if i want to avoid testcases
        fridge._testcases()

        #TODO: make the gui :DDD

        pass
Exemple #2
0
from kivy.uix.scrollview import ScrollView
from kivy.uix.textinput import TextInput
from kivy.uix.spinner import Spinner
from kivy.uix.popup import Popup

from kivy.config import Config

import datetime

from Fridge import Fridge
from FridgeItem import FridgeItem

import pickle

#global so i can save and load from it outside of the ItemDisplay
fridge = Fridge()
#global so i can reference it within the ItemDisplay
file_directory = "item_list.txt"


class ItemDisplay(GridLayout):
    '''
    TODO:
    format buttons!!!
        -expiry date buttons mainly
                                                        add good font
                                                        add variable reading from Item Name, Quantity (Number) and Quantity (Units)
                                                            -> then use that to make a new FridgeItem
                                                                ->check if the item is valid by checking all 6 variables
                                                        ^DONE
                                                        make inputting text not make user have to backspace everything,