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')