• tmessers

    @cvp
    Thank you, both hints worked well.

    posted in Pythonista read more
  • tmessers

    Hello everybody,
    i have a problem using location.geocode.
    By using a ui, i want to get the geocode of an
    address.

    Although from my view the dict is created properly,
    the result, when operated by location.geocode is „None„.
    I cant find my fault.
    Does anybody else find it?

    Thanks

    import ui
    import location
    
    
    def button_tapped(sender):
        if sender.title == "Execute":
            adresse()
            
        elif sender.title == "Delete":
            tf1.text = ""
            tf2.text = ""
            tf3.text = ""
        
        elif sender.title == "Map":
            lon=float(tf1.text)
            lat=float(tf2.text)
            karte(lon,lat)
    
    mg=20
    w=200
    h=30
    mg1=((2*mg)+w)
    mg2=((3*mg)+(2*w))
    bw=200
    
    def make_textfield(text,frame):
        return ui.TextField(text=text, frame=frame, bordered =True, clear_button_mode='always')
    
    def make_button(title, frame):
        return ui.Button(title=title, frame=frame, bordered=True, border_width=2,   action=button_tapped)
        
    v=ui.View(name='Koordinaten',bg_color='grey',tint_color='black',border_width=1)
    tf1=make_textfield(text='Street',frame=(mg,((2*mg)+h),w,h))#tf1
    v.add_subview(tf1)
    tf2=make_textfield(text='City',frame=(mg1, ((2*mg)+h),w,h)) #tf2
    v.add_subview(tf2)
    tf3=make_textfield(text='Country',frame=(mg2, ((2*mg)+h),w,h)) #tf2
    v.add_subview(tf3)
    tf4=make_textfield(text='tf4',frame=(mg1, ((3*mg)+(2*h)),w,h)) #tf2
    v.add_subview(tf4)
    tf5=make_textfield(text='tf5',frame=(mg2, ((3*mg)+(2*h)),w,h)) #tf2
    v.add_subview(tf5)
    
    v.add_subview(make_button(title='Execute',frame=(mg,((8*mg)+(7*h)),w,h)))
    v.add_subview(make_button(title='Delete',frame=(mg1,((8*mg)+(7*h)),w,h)))
    v.add_subview(make_button(title='Map',frame=(mg2,((8*mg)+(7*h)),w,h)))
    v.present()
    
    def adresse():
        #print("addresse ok")
        road=tf1.text
        #print(strasse)
        town=tf2.text
        #print(stadt)
        land=tf3.text
        #print(land)
        addresse= {'Street': road, 'City': town, 'Country': land}
        print ("1: %s" %addresse)
        results = location.geocode(addresse)
        print ("1: %s" %results)
        if results != None:
            zwischen1=round(results[0]['latitude'],6)
            tf4.text=str(zwischen1)
            zwischen2=round(results[0]['longitude'],6)
            tf5.text=str(zwischen2)
    
    

    posted in Pythonista read more
  • tmessers

    I mean, how can i name it by using the function to create it?
    Where in the documentation can i find information about it?

    posted in Pythonista read more
  • tmessers

    Thanks for the answers.
    Yes, i want to read the TextFields.
    How can i name them?

    posted in Pythonista read more
  • tmessers

    Hello everybody, within my code i am creating ui.TextFields by a function. I need the input of that TextFields as values for further calculations. My question is, how i can refer to that TextFields?
    Below i‘m showing my code with the GUI part.

    import ui
    
    def button_tapped(sender):
        if sender.title == "Umrechnen":
            lon = tf1.text 
                    Lat = tf2.text
        elif sender.title == "Felder leeren":
            tf1.text = ""
            tf2.text = ""
    
    mg=20
    w=100
    h=30
    mg1=((2*mg)+w)
    mg2=((3*mg)+(2*w))
    
    
    def make_label(text,frame):
        return ui.Label(text=text, frame=frame, bordered=True, border_width=2)      
    
    def make_textfield(text,frame):
        return ui.TextField(text=text, frame=frame, bordered =True, clear_button_mode='always')
    
    def make_button(title, frame):
        return ui.Button(title=title, frame=frame, bordered=True, border_width=2,   action=button_tapped)
    
    
    v=ui.View(name='Koordinaten',bg_color='grey',tint_color='black',border_width=1)
    v.add_subview(make_label(text="Nordwert",frame=(mg1, mg, w,h)))
    v.add_subview(make_label(text="Ostwert",frame=(mg2, mg,w,h)))
    v.add_subview(make_label(text="Dezimalgrad",frame=(mg,((2*mg)+h),w,h)))
    v.add_subview(make_textfield(text='',frame=(mg1,((2*mg)+h),w,h))) #tf1
    v.add_subview(make_textfield(text='',frame=(mg2, ((2*mg)+h),w,h))) #tf2
    v.add_subview(make_button(title='Umrechnen',frame=(mg1,((6*mg)+(5*h)),w,h)))
    v.add_subview(make_button(title='Felder leeren',frame=(mg2,((6*mg)+(5*h)),w,h)))
    v.present() ```
    
    Can anybody help me?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!