Python Script/gui question

556
1
06-22-2012 12:59 PM
AnthonyTimpson2
Occasional Contributor
Hello i have a script which uses win32gui.messagebox to alert users of the data being processed and to confirm that the code continues to run.

This works well and good when you run the script from the python window. Confirmations pop up, user clicks, program continues.

if the script is run from the toolbox the gui pop ups are ignored and all you can do is close them.

is there a way to make the toolbox version run the same as the copy/pasta version?
Tags (2)
0 Kudos
1 Reply
NobbirAhmed
Esri Regular Contributor
You can try creating a script tool with the Python script as the source. You can add Python code to show progression (by %) and show messages on tool dialog. If you use a script tool you won't have to worry about validation - the framework takes care of validation. You can even customize validation if necessary. You can use such a tool just like any system tool.

If you are interested start here:

A quick tour of creating script tools

Basically, you use either argv or arcpy.GetParameterAsText(index) to capture user input. You keep the user updated with messages using arcpy.AddMessage("message text"). To show progression, you can use SetProgressor, ResetProgressor and other progressor methods of arcpy.
0 Kudos