Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Another dialogue issue
-
@cvp but don’t you see that Newlink return None, before that?
This is the output when I type “This string” in the viewafter calling NewLink: None
from parse after dialog: {'name': 'This string'} -
@Tel Yes, I've seen but the only one print that proves, for me, that the wait_modal is ended is the "from parse", and this one comes only after I've pressed ok.
I agree it is strange -
@cvp so, back to my original point, the dialog should block the return out of Newlink, but it doesn’t. And there is nothing for me to put a wait_modal() on.
-
@Tel Could you, please, for my pleasure, try this modification and tell me if the print "after dialog" comes after you pressed ok
def textfield_should_return(self, textfield): st = textfield.text self.tv.text += '>'+ st + '\n' NewLink(st) #theModel.parse(st)
-
@cvp of course, but in order to see what’s happening you need to insert
print(NewLink(st))And you will see the same thing happens.
-
@Tel I really don't understand why you need this print because it will print the result of newlink it the print "after dialog" also.
-
@cvp that print is just to prove that NewLink has completed before the dialog OK has been pressed. Therefore the dialog did not block.
-
So NewLink() has completed. Now if there is a return(result) at the end of NewLink(), after the print, where does it return to?
-
@Tel ok, I can't help more, I'm sorry
-
@cvp thanks for your patience.
-
@Tel Agree, and that's why I say it is strange because the result in the print"after dialog" is correct...
-
For me, this is ok
@ui.in_background def parse(self,st) : r=NewLink(st) print('after calling NewLink:',r) #@ui.in_background def NewLink(st):
For the first time, console shows both line in the right order
from parse after dialog: {'name': 'Azert'} after calling NewLink: None
-
@cvp [i was taking a nap for a while] I’ll try that.
There’s obviously a lot I don’t understand about ui.in_background. -
@Tel that seems to do it!!! But I don’t understand it, do you?
-
@Tel The only thing I know is that there is a main thread with, normally all UI process, and another ui.in_background for other process (+ all threads you want, of course).
I know that wait_modal on a presented ui.View returns immediately if called in the main thread. That's why you should put the @ui.in_background in the function that calls form_dialog. But here you have a sequence of functions called until form_dialog, and thus not easy to say in which you have to put this décorationDoc says:
Wait until the view is no longer on screen. This can be useful for creating modal dialogs. If this is called from the main (UI) thread, e.g. via an action, it returns immediately. It also returns immediately if the view is not (yet) on screen. In typical usage, this is called directly after View.present().
-
@Tel said:
i was taking a nap for a while
a nap can be beneficial, the proof is that the problem seems solved 😂
-
@cvp well, I just can’t find the right place to put it in my program.
I will have to try another way entirely. -
@Tel Good thinking and good luck, sometimes needed 😀
If you think you need help, don't hesitate, this forum has a lot of smart and marvelous guys -
I think ui.in_background is not what you want. I'll take a look later tonight, but you should try using @run_async from the script I linked to earlier.
-
I think I found the right place for it.
@ui.in_background def got_input(st) : theModel.parse(st)
That works in my program too.
Thanks everyone for running such a patient and informative forum.