• recon22

    Hello @cvp ,

    I tried the code out in Pythonista and I was able to run my app and get the coordinates successfully...

    However!

    When I placed it in the app template provided by @omz and tried the location module I was not able to use it. The error message I received was

    Traceback (most recent call last):
      File "/var/mobile/Containers/Data/Application/11A60AF2-A1D5-4F30-981C-7A65792D1D3A/Library/Application Support/PythonistaScript/main.py", line 24, in currentlocation_tapped
        gpslongitude = currentlocation.get("longitude")
    AttributeError: 'NoneType' object has no attribute 'get'
    
    

    Will the location module work once the app is published on the App Store? Will the user be able to allow the location in the settings at that point?

    Currently, when I load the app onto my iPhone for testing, when I go to my settings to set the privacy options to allow geo-location for my app it shows it as 'Never' then when I click that and go back I am allowed to choose 'Always', not sure why that is happening or if that is the cause of the issue...

    Not sure why the location module is working fine with the same code within Pythonista and behaves differently(throws errors) when loaded into xCode.

    --------SOLVED--------
    I needed to update the info.plist to include the various location usage keys and accompanying string.

    posted in Pythonista read more
  • recon22

    Hi @cvp

    Thank you for the speedy reply. There was a typo in my original post. I did have the .text suffix.

    Everything prints out fine except the str(currentlocation).It just returns None.

    I checked by adding +str(location.is_authorized) and have received a string that says the module is authorized.

    posted in Pythonista read more
  • recon22

    Hello,

    I have the following code:

    def currentlocation_tapped(sender):
           location.start_updates()
           currentlocation = location.get_location()
           CURRENTCOORDINATES = sender.superview['currentcoordinates']
           CURRENTCOORDINATES.text = "Current Coordinates : " + str(currentlocation)
           location.stop_updates()
    

    When I try to run this to update my textview text it returns none. I have to go manually to the settings to turn on location services for the app when testing and still I receive "None" as a returned string.

    Is there an error with how I am naming variables? Has anyone used this function successfully, I have seen others remarking that this function has not worked for them while the other ones in the module have.

    Thank you!

    posted in Pythonista read more
  • recon22

    Has anyone published an app with python 3?

    I'm looking to get my script working as a stand alone app, are there any workarounds?

    posted in Pythonista read more
  • recon22

    Thank you beautiful people! Your suggestions worked! I'm working on limiting the characters entered and auto hiding the keyboard when trying to the character limit!

    posted in Pythonista read more
  • recon22

    @JonB

    Hello Jon, I do have a create button when pushed converts the entered text and creates a KML.

    How can I tie the two together?

    posted in Pythonista read more
  • recon22

    Hello,

    I've created a simple program to convert coordinate systems and am stuck on how to save user data entered into 3 different textfields to their respective string variables(basemap,zone,block)

    I've seen the delegate solution but have trouble comprehending what is occurring. Is there a simple solution to this by creating a function?

    SOLVED-> Also, I've tried to set the default keyboard to only show the phone pad but it is still showing the default keyboard.

    Here is my code :-------

    import sys
    import os
    import time
    import utm
    import simplekml
    import console
    
    #run the GUI
    
    import ui
    tf = ui.TextField()
    tf.keyboard_type = ui.KEYBOARD_NUMBER_PAD
    
    #def text_field_action(sender):
    #   v = ui.load_view('UTM2KML.pyui')
    #   tf = v['basemaptext']
    #   tf.action = text_field_action
    def getInput(view):
        textfield = view["textfield name"]
        input = textfield.text
        return input
        
        
    def mainscreen():
        BASEMAP = getInput("basemaptext")
        BLOCK = getInput("blocktext")
        ZONE = getInput("zonetext")
    
    def createbutton(sender):
    #basemap
    #block
    #zone
        BASEMAP = getInput("basemaptext")
        BLOCK = getInput("blocktext")
        ZONE = getInput("zonetext")
    
    
        #The syntax is utm.to_latlon(EASTING, NORTHING, ZONE NUMBER, ZONE LETTER).
        BLOCK = "00"
    #converts the strings to ints
    #BASEMAP = int(BASEMAP)
        ZONE = int(ZONE)
        if BLOCK == "":
            EASTING = BASEMAP[0:-3] + BLOCK[0:-1] + "0000" 
            NORTHING = BASEMAP[2:] + BLOCK[1:] + "0000"
            EASTING = int(EASTING)
            NORTHING = int(NORTHING)
        
        else:
            EASTING = BASEMAP[0:-3] + BLOCK[0:-1] + "000" 
            NORTHING = BASEMAP[2:] + BLOCK[1:] + "000"
            EASTING = int(EASTING)
            NORTHING = int(NORTHING)
        
    #print(EASTING)
    #print(NORTHING)
        int(EASTING)
        int(NORTHING)
        int(ZONE)
    
    #Return (LAT,LONG)
    #print("Latitutde, Longitutde in Decimal Degrees")
    
    #print(utm.to_latlon(EASTING,NORTHING,ZONE,'N'))
    #split and reverse for the kml conversion
        location = str(utm.to_latlon(EASTING,NORTHING,ZONE,'N'))
    
        lati = location.split(',')[0]
        longi = location.split(',')[1]
        kmllocation =(longi.strip("()"),lati.strip("()"))
    #Create the kml file
        kml = simplekml.Kml()
        kml.newpoint(name="WAYPOINT", coords=[(kmllocation)])
    #save kml location
        kml.save("Waypoints.kml")
        console.open_in("Waypoints.kml")
        
    
    v = ui.load_view('UTM2KML').present('fullscreen')
    #v.present('fullscreen')
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!