def onChangeLoc(self, event):
'''
Change location
'''
loc_set = False
while not loc_set:
dlg = wx.TextEntryDialog(self.frame, 'Please enter a location', 'Current location: ' + self.location)
if dlg.ShowModal() == wx.ID_OK:
# do something here
loc = str(dlg.GetValue())
else:
# handle dialog being cancelled or ended by some other button
loc = None
dlg.Destroy()
geolocator = Nominatim()
# Look up location given
try:
l = geolocator.geocode(loc, exactly_one=True)
self.latlon = (l.latitude, l.longitude)
self.location = loc
loc_set = True
except Exception as e:
print('Error setting location\n' + str(e))
self.session.update_location(self.latlon[0], self.latlon[1])
评论列表
文章目录