class UpdateScreen(Screen): """data contains a list of all dicts displayed for a selection in the dropdown""" disp_data = [] json_data = loader() key = '' hint_text_1 = StringProperty('') hint_text_2 = StringProperty('') def save(self): Factory.VerifyPopup(data = self.json_data).open() def clear(self): self.rv.data = [] self.disp_data = [] def add_entry(self): try: self.disp_data.append({'selection': str(self.input_1.text), 'pair': str(self.input_2.text)}) self.json_data[self.key].update({self.input_1.text: self.input_2.text}) self.rv.data = self.disp_data self.input_1.text = '' self.input_2.text = '' except: Factory.ErrorPopup().open() def delete(self): temp = self.disp_data for index, item in enumerate(reversed(self.rvlayout.children)): if item.selected: self.json_data[self.key].pop(item.selection) i = temp.index({'selection': item.selection, 'pair': item.pair}) temp.pop(i) print(temp.pop(index)) self.clear() self.disp_data = temp self.rv.data = temp def populate(self, key): data = self.json_data[key] self.clear() for item in data: self.disp_data.append({'selection': str(item), 'pair': str(data[item])}) self.rv.data = self.disp_data self.key = key
def __init__(self, **kwargs): super(SelectionDropDown, self).__init__(**kwargs) self.types = loader() self.default_text = "Choose category to edit" self.text = "Choose category to edit" self.name = "selection"
def __init__(self, **kwargs): super(DropSolvents, self).__init__(**kwargs) self.types = loader()['Solvents'] self.default_text = "Solvent" self.text = "Solvent" self.name = "dens"
def __init__(self, **kwargs): super(DropSolutes, self).__init__(**kwargs) self.types = loader()['Solutes'] self.default_text = "Solute" self.text = "Solute" self.name = "solts"
def __init__(self, **kwargs): super(DropTypes, self).__init__(**kwargs) self.types = loader()['Types'] self.default_text = "Type of Solution" self.text = "Type of Solution" self.name = "type_solution"