AnsweredAssumed Answered

Python Add-In Message Box interaction

Question asked by Cep86 on Aug 17, 2015
Latest reply on Aug 17, 2015 by Cep86

I have an add-in created, and it runs the tools as needed.  I would like to expand upon those tools to add some checks and balances with questions via the MessageBox function.  I can add message boxes just fine, but I'm trying to figure out how to script the *_addin.py file so that it does certain things based on the answer to the message box.

 

I have a simple message box shown below:

pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)

 

This creates the Yes/No message box, and works just fine on its own.  The problem now is that I'm not sure how to make Yes run the tool, while No stops the tool. 

 

I've tried the following with no luck.

 

pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
     pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')  # toolPath is declared at the top...works without the MB

 

and

 

mbAnswer = pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
     if mbAnswer = 'Yes':
          pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')
     else:
          pass

 

I can't seem to find anything online regarding how to use the user inputs to determine what to do when clicked.  I've found stuff about "Tkinter" and stuff similar, but nothing about the pythonaddins.MessageBox option. 

 

Thanks!

Outcomes