title: Creating a form to populate a database in Kivy
body: <p>The end goal is to create entries in a database with info from a form, using a variety of widgets (textinput, checkboxes,etc). I wanted to make a button at the end of the form to submit the responses to a dict, but I am getting stuck. The only way I can think of to accomplish this is to make all the ids to object properties, then individually reference them in a function like series1.value... series2.value...</p>
  
  <p>This seems very cumbersome and would make it difficult to add further entries to the form later on.</p>
  
  <p>Here is my .py:</p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.boxlayout import BoxLayout
  from kivy.properties import ObjectProperty
  from kivy.uix.checkbox import CheckBox
  from kivy.uix.togglebutton import ToggleButton
  from kivy.uix.button import Button
  
  
  class DermRoot(BoxLayout):
      dict_filled_from_form = {}
      def add_entry_to_db(self,dict_filled_from_form):
          pass
  
  class DemographForm(BoxLayout):
      sex = ObjectProperty()
      age_input = ObjectProperty()
  
      def add_entry(self,dict_of_form):
          dict_filled_from_form = dict_of_form
          #is this possible?
          #or do I have to do dict_filled_from_form['series1'] = series1.value etc
  
  class DermApp(App):
      pass
  
  if __name__ == '__main__':
      DermApp().run()
  </code></pre>
  
  <p>and my kv file</p>
  
  <pre><code>DermRoot:
  
  &lt;DermRoot&gt;:
      DemographForm
  
  &lt;DemographForm&gt;:
      orientation: "vertical"
  
      GridLayout:
          age_input: age_input
          sex: sex
  
          cols: 2
          Label:
              text: "Patient's Age:"
          TextInput:
              id: age_input
              focus: series4
              multiline: False
          Label:
              text: "Sex:"
          ToggleButton:
              id: sex 
              text: "Male" if self.state == 'normal' else "Female"
          Label:
              text: "Standard Series to Include?"
          GridLayout:
              series1: series1
              series2: series2
              series3: series3 
              series4: series4
              series5: series5
  
              cols: 2
              CheckBox:
                  id: series1
              Label:
                  text: "Series1"
              CheckBox:
                  id: series2
              Label:
                  text: "Series2"
              CheckBox:
                  id: series3
              Label:
                  text: "series"
              CheckBox:
                  id: series4
              Label:
                  text: "series4"
              CheckBox:
                  id: series5
              Label:
                  text: "Series 5"
      Button:
          height: "40dp"
          size_hint_y: None
          text: "Add Entry to Database"
          on_press: root.add_entry(dict_of_form = 'how do I get this?')
  </code></pre>