I made a simple toolbar of 2 buttons to export the map into JPEG and PDF using Python Add-in wizard.
However, I wanted to improve the script such that when I click the button, it will prompt a window to select the location to place the file, and also input the file name.
Does any know how to do it? The present script is pasted below.
Thanks!
-----------------
import arcpy
import pythonaddins
class export2_jpg(object):
"""Implementation for export2_jpg_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
mxd = arcpy.mapping.MapDocument('current')
arcpy.mapping.ExportToJPEG(mxd,r'C:\Users\xx\Desktop\output.jpg, resolution=300')
pass
class export2_pdf(object):
"""Implementation for export2_pdf_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
mxd = arcpy.mapping.MapDocument('current')
arcpy.mapping.ExportToPDF(mxd,r'C:\Users\xx\Desktop\output.pdf')
pass
Solved! Go to Solution.
Have a look at pythonaddins.SaveDialog.
Have a look at pythonaddins.SaveDialog.
Thanks!