Monday 23 September 2019

Code to open web browser crashes ArcMap when run from a Python add-in


I created an ArcMap Python add-in using ArcGIS 10.1 to open a webpage after the map is clicked. It opens the page but then ArcGIS crashes.


import arcpy
import pythonaddins
import webbrowser

class ToolClass2(object):
"""Implementation for TEST_addin.tool (Tool)"""
def __init__(self):
self.enabled = True
self.cursor=3
def onMouseDownMap(self, x, y, button, shift):

mxd=arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd)[0]
pt=arcpy.PointGeometry(arcpy.Point(x,y))

pythonaddins.MessageBox("Long" + " " + str(x) + '\n'+ "Lat"+ " " + str(y), 'Coordinates', 0)
path = 'http://pol.pictometry.com/en-us/php/default.php?lat=' +str(x) +'&lon=' + str(y)+'&v=p&o=n&type=or&level=n'
webbrowser.open(path)
pass


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...