0

I am developing a toolbar by the pythonaddins, in regards to define all the input raster files. I wrote the follwoing lines so the user enters how many data he wants to read and accordingly, an input box will be displayed

# Import
import arcpy, os,sys, pythonaddins

Folder_Location = arcpy.GetParameterAsText(0) # please select a folder to save the project files
ScN=arcpy.GetParameterAsText(1) # please write the number of scenarious to be compared
#-----------------------#
ScN=int(ScN)
for i in range (1,int(ScN)+1):
    MessageD='Select the raster layer of flood depth for scenario No   '#+ str(i)
    Depth_rstr[i]= pythonaddins.OpenDialog(MessageD,False,r'C:\','Select')

unfortunatly, the OpenDialog window just display folders without allowing me to double click it to select any file

enter image description here

hoowever when I write the same lines in python window, it works well

enter image description here

I notices when I operate this puthonaddins- button, I got this error in the python window

TypeError: GPToolDialog() takes at most 1 argument (2 given)

Could any one advice me, how to solve this problem? I want this could to select files.

0

I cannot see this coding pattern working because you are trying to use the pythonaddins module, which is designed for Python AddIns, within a Python Script Tool.

The pythonaddins module documentation explicitly says right at its start:

The pythonaddins module can only be used within a Python add-in. It cannot be used in stand-alone scripts or geoprocessing script tools.

I think you should remove the pythonaddins module from your code and configure another parameter on the tool dialog of your Python Script tool instead.

  • I use these scripts within The pythonaddins. I have developed a toolbar, and script in the ToolBox the buttons in the toolbar are just operate the toolbox script using pythonaddins.GPToolDialog(r'D:\.......) – A.Adel Saleh Sep 22 '16 at 10:38
  • Are you saying that you have not included a code snippet that works up to where you are stuck? If that is the case then please review meta.gis.stackexchange.com/questions/4312/… and revise your question. – PolyGeo Sep 22 '16 at 10:41
  • Well, I will have a look< thank you hope I didn;t bother you – A.Adel Saleh Sep 22 '16 at 10:53
  • Could you please tell me what parameters in Python Script that read files' paths within a loop instead of pythonaddins.OpenDialog. Thanks – A.Adel Saleh Sep 23 '16 at 18:11
  • I suspect that you should be using a multi-value on that parameter. – PolyGeo Sep 23 '16 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.