Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to have the script dialog box have the radio button that says "Close this dialog when completed successfully" unchecked for any user who runs the script tool? Is there configuration somewhere to do this? Thanks.

share|improve this question
add comment

4 Answers 4

up vote 5 down vote accepted

ArcGIS stores a great deal of a user's preferences in the Windows Registry, which is partially documented in "ArcGIS Desktop Advanced Settings Registry Keys.doc", found in the Utilities folder of your ArcGIS installation. You can browse these settings with the Registry Editor (run regedit), and look into the keys from HKEY_CURRENT_USER\Software\ESRI.

This particular feature asked in the question can be modified using Python (at your own risk!):

import _winreg as reg

# Get registry key for ArcToolbox processing dialog (ATPD):
ATPD_key = reg.OpenKey(reg.HKEY_CURRENT_USER,\
                       r'Software\ESRI\ArcToolbox\ATProgressDialog', 0, reg.KEY_ALL_ACCESS)

# Get current status of AutoClose
autoclose_before = bool(reg.QueryValueEx(ATPD_key, 'AutoClose')[0])
print('AutoClose before: ' + str(autoclose_before))

if autoclose_before:
    print('Turning off AutoClose')
    reg.SetValueEx(ATPD_key, 'AutoClose', 0, reg.REG_DWORD, int(False))

You can place snippets of this in def __init__(self) of the script validation, which runs before the toolbox progress dialog. However, if a user actually prefers to have the AutoClose checked, I'm not sure how to set it back after the script has finished, unless you store autoclose_before somewhere in the registry and do a similar post-set in your geoprocessing script. But you've been warned, this is Python hackery!

share|improve this answer
add comment

Based upon your comments in other responses, it sounds like you really just want to alert the user about things that have occurred during the operation of your script, rather than necessarily keep the script dialog box open.

A couple of alternative approaches could be:

  • Write the pertinent information back to the ArcGIS GP console by adding messages, warnings, and errors calls to your script. If the user simply unchecks the "Close this dialog when completed successfully", you pass all the info you want into the text box.
  • Write all the pertinent information to a log file. You could add a checkbox to your script to "View Log File" (checked on by default) that would open the log file after the process completes (to success or failure) using "os.startfile(your_log_file)", which would open the log file in it's default application.
share|improve this answer
    
Your right, my question is more like you stated. Thanks for the answer as it answers my real question. –  Justin Jan 26 '12 at 16:36
    
+1 for logging, it's so easy to do with the logging module and log files take up so little space, there's no reason not to do it. –  Chad Cooper Jan 26 '12 at 18:05
    
Since he won't mention it himself, @ChadCooper wrote an article about ArcPy and logging that was posted in ArcUser back in 2008. –  RyanDalton May 7 '12 at 20:01
add comment

A clean, no fuss alternative would be to display your log file in a simple Tkinter window at the end of your script. While the registry option is workable, there may be forces beyond your control, admin privileges, etc.

if showLog:
    import Tkinter
    #read the log data
    log = open(r'logfile.txt').read()

    #create a tkinter window with a text box
    root = Tkinter.Tk('Geoprocessing Log File')
    txt = Tkinter.Text(root)
    txt.pack()
    btn = Tkinter.Button(root,text='Close',command=root.destroy)
    btn.pack()
    txt.insert(Tkinter.END,log)
    root.mainloop()
share|improve this answer
add comment

No, not possible for all scripts or for individual ones.

share|improve this answer
    
Is there some other way to get info about the script run to the user that would stay open past the run of the script. The issue is that I have vital info about what was found and more importantly what was not found on long running scripts. So the user usually kicks it off at night then when back to the computer the dialog is gone. win32gui didn't work too well because I had to go around installing it on users computers(if I was doing it right). Thanks. –  Justin Jan 26 '12 at 2:03
    
The usual method for long running tasks would be to write the pertinent info to a log file. Its much cleaner than using the geoprocessing window. –  tharen Jan 26 '12 at 10:03
    
I have the info in logging but then how would I dialog back to the user to go to the log file in a clean and polished manner? I could have the user enter his email address and email them but this seems to intrusive. –  Justin Jan 26 '12 at 13:44
2  
Dan, with software often "not possible" is not a hard and fast characterization: there may be clever workarounds or options for dedicated savvy programmers. I'm not asking you to elaborate on just how impossible this is, but would you be able to supply a reference or some evidence of the impossibility? –  whuber Jan 26 '12 at 14:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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