Use file dialogs for feature layer input selection in PythonWin

516
7
04-13-2011 02:16 PM
GuyDuke
New Contributor
Hi all,

Does anyone know if it's possible to call the file dialog to select multiple Feature Layers for input into a script run through PythonWin?  That is to say, the nice litte file dialog that we have access to for selecting multiple feature layers when the script is run out of ArcToolbox.  I'm trying to migrate from old VB6 & VBA and I'll admit that PYTHON is VERY efficient but I'm stuggling royally with the PYTHON IDE's...on a few levels.  I find it easier to test and run out of PythonWin.  On a completely unrelated note...why can't the toolbox results window simply recognize the print statement?  I miss good old VBA.  It may have taken a lot of code, but debugging was a dream.  Python programming between PythonWin and code run through toolbox seems like it takes two different versions just to get some feedback!

Thanks.
Tags (2)
0 Kudos
7 Replies
TerrySilveus
Occasional Contributor III
I didn't look at the previous suggestion, but if it doesn't help, and since you say it's just for testing, why not hard code your file names?  I'll take some time to look at the other suggestion tomorrow, but what I generally do for testing is hardcode my "soon to be" parameters for arcGIS tools while I'm testing in IDLE or WinPy
0 Kudos
GuyDuke
New Contributor
Thanks Dan & Teresa...

Hmmm...I was hoping I wouldn't have to use Tkinter but yes I do see (sort of) how something could be put together for what I want.  I think this might be one way that VBA was superior...maybe not surprising considering Windows and VBA are both Microsoft.  Maybe I'll add this to the ArcGIS Ideas resource center.  It seems to me that the forms / dialogs that ArcMap uses (or something like them built for Python using Tkinter) should be available as modules and callable with a single line of code.
0 Kudos
LoganPugh
Occasional Contributor III
If you don't want to reinvent the wheel and instead use premade dialogs, you could use comtypes and ArcObjects, e.g. the IGxDialog interface.

See here: http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python
0 Kudos
GuyDuke
New Contributor
Logan - accessing ArcObjects from Python sounds VERY promising indeed!  But I can't find DemoTool.idl.  Do you know where this should be?  I've got visual studio, the WinSDK, and ran the comtypes exe from sourceforge.
0 Kudos
LoganPugh
Occasional Contributor III
I think that's part of Mark Cederholm's sample code: http://www.pierssen.com/arcgis/upload/misc/python_arcobjects.zip
0 Kudos
MarkCederholm
Occasional Contributor III
This thread has been brought to my attention, and it seems there are some misconceptions floating around. You do NOT need Visual Studio, or the MIDL compiler, or even PythonWin in order to use ArcObjects in Python; all you need is the comtypes package. My presentation included an advanced exercise in creating a COM component using Python, but that was meant for UberPyGeeks. The snippets.py file contains all the examples you need.
0 Kudos