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.
Form Dialog Returning None
-
I am finishing a script that uses a ui to add a reminder using the reminder module. In the last section of the script is the location alarm code. I am using a list dialog to select a location. At the end of the list is custom.
When you click custom, it presents a form where you input the street, city, and state. It then uses the location module to convert the address to geocode, and uses the geocode for the reminder.
This process has always worked, and I have never had trouble with it. Now that I am trying to put it in a ui script, the form is returning None. The code appears to be perfectly fine, and when I try to use the same system in the console, it works perfectly. Only in the script does it return None.The section of the script looks like this:
self.wait_modal() a = reminders.Alarm() address_dict = dialogs.form_dialog('test', [{'title': 'Street', 'type': 'text'}, {'title': 'City', 'type': 'text'} , {'title': 'State', 'type': 'text'}, {'title':'Country', 'type': 'text', 'value': 'USA'}]) results = location.geocode(address_dict) if self.radiusswitch.selected_index == 0: a.proximity = 'enter' if self.radiusswitch.selected_index == 1: a.proximity = 'leave' lat = results[0]['longitude'] lng = results[0]['latitude'] radius = 500 reverse = location.reverse_geocode(results) title = reverse[0]['street'] a.location = (title, lat,lng) v.r.alarms = [a] v.r.save()``` The var that returns None is address_dict. Is there any reason why it might be returning None?
-
What happens when you comment out
self.wait_modal()
? -
@ccc When I take out that line it throws an error saying that a ui or view is already being presented.
-
self.wait_modal() time.sleep(1) # ...
-
is this inside a button action perhaps?
You cannot put a blocking function inside a button action, or other methods that are called on the ui thread. The calls to the form need to be called as @ui.in_background if that is the case.
There may be an issue which I have noticed recently when dealing with for examples the photos picker, that presenting a view while another is closing might lead to issues. yOu might try adding a time.sleep() after wait_modal, since this implies you have another view which is getting closed right before this chunk executes.
It might be helpful to see the entire method, or a complete standalone example that shows the issue.