@JonB here is a cut down version showing the problem. You will see that the calling thread continues while the dialog is still up.
```
import sys, dialogs
import ui
import console
import controller
global theView
class MyView(ui.View):
last_content_offset = (-1,-1)
def init(self, args, *kwargs):
super().__init__(*args, **kwargs)
self.make_view()
self.value = None
def make_view(self):
self.tv= ui.TextView(title='textview1', frame=self.bounds.inset(10,10),editable = False, border_width=2, bg_color='white', flex='hw')
self.update_interval = 1/60
self.tv.height = self.bounds.height-70
self.add_subview(self.tv)
tf = ui.TextField(frame = self.bounds.inset(10, 10), text_color='red')
#print (self.bounds)
tf.frame=(10,240,self.bounds.width-20,40)
tf.height =32
tf.delegate = self
tf.flex = 'w'
tf.begin_editing()
self.add_subview(tf)
def update(self) :
self.tv.content_offset = (0, self.tv.content_size[1] - self.tv.height)
if self.tv.content_offset[1] < 0:
self.tv.content_offset = (0,0)
#if self.tv.content_offset != MyView.last_content_offset :
#print ('*',self.tv.content_offset, self.tv.content_size, #self.height)
MyView.last_content_offset = self.tv.content_offset
def feedback(self, st):
self.tv.text += st +'\n'
def textfield_did_change(self, textfield):
self.value = textfield.text
def textfield_should_return(self, textfield):
st = textfield.text
self.tv.text += '>'+ st + '\n'
parse(st)
textfield.text=''
return True
def delayed_close(self) :
self.feedback('shutting down...')
ui.delay(self.close, 5)
def feedback(st):
global theView
theView.feedback(st)
def startView():
global theView
print('starting View')
theView = MyView(frame = (0,0,800,300), bg_color='white')
theView.present(style='sheet', animated=False)
return theView
this routine copied from forum, without the decoration, the dialog never gets input, have to cancel Pythonista
@ui.in_background
def myform_dialog(title='', fields=None,sections=None, done_button_title='ok'):
global c
sections = [('', fields)]
c = dialogs._FormDialogController(title, sections, done_button_title=done_button_title)
c.container_view.frame = (0, 0, 500,900)
c.container_view.present('sheet')
c.container_view.wait_modal()
# Get rid of the view to avoid a retain cycle:
c.container_view = None
print('from myform_dialog:',str(c.values))
if c.was_canceled:
return None
return c.values
this part actually in the model
def parse(st) :
fields = [{'title':'name','type':'text','value':st} ]
result = myform_dialog(title='Link design', done_button_title='ok',fields=fields, sections=None)
feedback(str(result))
print('from parse:',result)
if name == "main":
console.clear()
#show just ui
startView()
```