title: Creation of an input dialog using Kivy
body: <p>I would like to create a function which only returns its value once the user input text into a TextInput and click on an ok button.  For example</p>
  
  <pre><code>n = PopupInput("What number should I add?")
  print 5+n
  </code></pre>
  
  <p>I can't figure out how to write a kivy dialog which will pause execution and wait until the user closes it.  In other GUI toolkits, I would have used something like</p>
  
  <pre><code>while True:
     if dialog.visable == False:
        return int(textbox.text)
     else:
         wx.Yield()
  </code></pre>
  
  <p>To allow my code to just sit in one spot while allowing the GUI framework to do its thing.  However, I can find no equivalent method for Kivy.</p>
  
  <p>EDIT:</p>
  
  <p>Here's my unsuccessful attempt (its messy)</p>
  
  <pre><code>def PopupOk(text, title='', btn_text='Continue'):
      btnclose = Button(text=btn_text, size_hint_y=None, height='50sp')
      content = BoxLayout(orientation='vertical')
      p = Popup(title=title, content=content, size=('300dp', '300dp'),
                  size_hint=(None, None))
      content.add_widget(Label(text=text))
      ti = TextInput(height='50sp', font_size='50sp', input_type='number')
      content.add_widget(ti)
      def _on_d(*args):
          p.is_visable = False
      p.bind(on_dismiss=_on_d)
      p.is_visable = True
  
      content.add_widget(btnclose)
  
      btnclose.bind(on_release=p.dismiss)
      p.open()
      while not p.is_visable:
          EventLoop.idle()
     return ti.text
  </code></pre>