how to add user input of file path in Python Add-in script?

5388
2
Jump to solution
07-30-2015 07:47 AM
SiyangTeo
Occasional Contributor

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

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor
2 Replies
Luke_Pinner
MVP Regular Contributor

Have a look at pythonaddins.SaveDialog.

SiyangTeo
Occasional Contributor

Thanks!

0 Kudos