def get_line_items_contents(holder_layout, **kwargs):
    """Takes a layout containing at least one layout with two fields and a button, and returns the contents of those fields as a list of strings. If the 'as_dictionary' flag is set, the function returns the contents of those field as a dict of strings and floats."""
    as_dictionary = kwargs.get("as_dictionary", False)
    contents_of_all_fields = []
    for l in holder_layout.children():
        contents_of_all_fields.append(l.itemAt(0).widget().text())
        contents_of_all_fields.append(l.itemAt(1).widget().text())

    if as_dictionary:
        first_values = contents_of_all_fields[0::2]
        second_values = contents_of_all_fields[1::2]
        second_values_as_floats = [float(i) for i in second_values]
        return dict(zip(first_values, second_values_as_floats))
    else:
        return contents_of_all_fields