Exemplo n.º 1
0
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
Exemplo n.º 2
0
 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"
Exemplo n.º 3
0
 def __init__(self, **kwargs):
     super(DropSolvents, self).__init__(**kwargs)
     self.types = loader()['Solvents']
     self.default_text = "Solvent"
     self.text = "Solvent"
     self.name = "dens"
Exemplo n.º 4
0
 def __init__(self, **kwargs):
     super(DropSolutes, self).__init__(**kwargs)
     self.types = loader()['Solutes']
     self.default_text = "Solute"
     self.text = "Solute"
     self.name = "solts"
Exemplo n.º 5
0
 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"