Hi Terry,

Thanks for the fix. I see you also updated the encoding for the Quit button 
("TERMINATING SERVER"). I thought I might be spending an afternoon learning 
how to use git diff :) Maybe soon....
I have updated the docstring using the instructions from this thread and 
attached the file. Please feel free to change any terminology or style if 


On Saturday, February 3, 2018 at 3:38:49 AM UTC+11, Terry Brown wrote:
> I've made the necessary changes in 
> https://github.com/leo-editor/leo-editor/commit/9057d5b 
> Cheers -Terry 

You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.
#@+node:tbrown.20091214233510.5347: * @file geotag.py

A web app to obtain geotagging location data, and tag nodes with latitude and longitude.

There are 3 commands available via Alt-X or from the plugin's submenu. 


- Opens a browser web app to view the Geotagger map.


- Sets Leo to wait for a geotag to be sent from the geotagging web app.  **IMPORTANT** this blocks (stops leo) until it gets a response (i.e. 
  you click 'Send' in the geotagging web app.)  So you should (a) save 
  your outline before using it, and (b) do geotag-open-server-page, so 
  the web app. is available.


- show the node's location/geotag data in the map.

There are 2 buttons in the browser web App: 
[Send]  [Quit]


Issue the `geotag-open-server-page` command to open the web app. 

In Leo create a node associated with a place.
>From the node, issue the `geotag-tag-node` command. 

In the browser window, set the map pin to desired location.
Click the [Send] button to send coordinate information to leo, where it's stored in the headline of the @LatLng child node. 

To close the server, click [Quit]


#@@language python
#@@tabwidth -4

#@+<< imports >>
#@+node:tbrown.20091214233510.5349: ** << imports >>
import leo.core.leoGlobals as g

from leo.plugins.pygeotag import pygeotag

import socket
#@-<< imports >>
__version__ = "0.1"

#@+node:tbrown.20091214233510.5351: ** init
def init():
    '''Return True if the plugin has loaded successfully.'''
    if not hasattr(g, 'pygeotag'):
            g.pygeotag = pygeotag.PyGeoTag(synchronous=True)
        except socket.error:
            g.es('Geotag plugin init failed, perhaps port in use')
    return True
#@+node:tbrown.20091214233510.5352: ** onCreate
def onCreate (tag,key):

    c = key.get('c')

#@+node:tbrown.20101103145611.5658: ** onQuit
def onQuit(tag,key):
#@+node:tbrown.20091214233510.5353: ** class geotag_Controller
class geotag_Controller(object):

    '''A per-commander class that manages geotagging.'''

    #@+node:tbrown.20091214233510.5354: *3* __init__
    def __init__ (self, c):

        self.c = c
        c.geotag = self
    #@+node:tbrown.20091215204347.11403: *3* getAttr
    def getAttr(p):
        for nd in p.children():
            if nd.h.startswith('@LatLng '):
            nd = p.insertAsLastChild()
        return nd
    #@+node:tbrown.20091214233510.5356: *3* callback
    def callback(self, data):

        c = self.c
        p = c.p

        nd = self.getAttr(p)

        nd.h = '@LatLng %(lat)f %(lng)f %(zoom)d %(maptype)s  %(description)s ' % data
        if hasattr(c, 'attribEditor'):
#@+node:tbrown.20091214233510.5357: ** cmd_open_server_page (gettag_Controller)
def cmd_OpenServerPage(event):
    # c = event.get('c')
    # g.pygeotag.callback = c.geotag.callback

#@+node:tbrown.20091214233510.5358: ** cmd_tag_node (gettag_Controller)
def cmd_TagNode(event):
    c = event.get('c')
    data = g.pygeotag.get_position({'description':c.p.h})
#@+node:tbrown.20091215204347.11402: ** cmd_show_node (gettag_Controller)
def cmd_ShowNode(event):
    c = event.get('c')
    nd = geotag_Controller.getAttr(c.p)
        txt = nd.h.split(None, 5)
        what = 'dummy', 'lat', 'lng', 'zoom', 'maptype', 'description'
        data = dict(zip(what, txt))
        data['lat'] = float(data['lat'])
        data['lng'] = float(data['lng'])
        if 'zoom' in data:
            data['zoom'] = int(data['zoom'])
        if 'description' not in data or not data['description'].strip():
            data['description'] = c.p.h
    except (ValueError,TypeError):
        data = {'description':c.p.h}

Reply via email to