0

I am using an app called Pythonista on my iPhone. It functions much like any Python IDE but with a few additional features to account for the fact that is on iOS. It has a module called "dialogs" which is an objective-c wrapper for different UIs. One of them is called a form dialog, which is a UI with multiple text fields that are configured by a dictionary. The documentation for this module is online, if you search for 'pythonista dialogs module'.

My form dialog has text fields for address input (one for street, one for city, and one for state). When you put in your address, the results are fed into the location module, which converts them to geocode. It has always worked in other scripts.

Now, I am trying to make a script that uses a UI to add reminders, via a module that provides access to the iOS reminders app. To add a custom location for a location based alarm, I am using this form, which then uses the geocode for the reminder.

The form dialog is returning None, no matter what is entered into it. I assigned it a variable and used it in the same way that has worked before. I had a friend who is extremely good at Python check the script, and he found nothing wrong. When I run just the part that takes the address and converts it to geocode in the console, it appears to work perfectly, but in my reminder script, it only returns None.

There appear to be no errors with the script, which looks like this:

if self.locationlist.selected_row == (0,5):     
   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()

Is there any reason why the form might be returning None?

Sir Platypus
  • 543
  • 1
  • 4
  • 9
  • Looks like you've got the assignments to 'lat' and 'lng' the wrong way round. Apart from that, I have no idea what this code is doing. What object is 'self' in this case? What object is the form? At which point and into what variable is the form returning 'None' and how do you know? Where do 'v' and 'v.r' come from and what are they? To be honest, even answering the above questions probably wouldn't be enough to be able to help you. – Simon Hibbs Apr 19 '17 at 13:19
  • Most of those questions would involve pasting the entire 300 line script into the question. V represent another class, where the object is the ui view. R is the reminder object. Self is for the class that those lines are in, which also has a ui view. The form returns None into the var 'address_dict'. What do you mean by what object is the form? (I'm fairly new at this) – Sir Platypus Apr 19 '17 at 13:48
  • At least we need to see what dialogs.form_dialog() is doing as that's the code that's returning the value. I'd assumed this code was part of the dialog. – Simon Hibbs Apr 20 '17 at 08:38

0 Answers0