How to show Messagebox in ArcMap 10.1 through using Python?

5908
2
Jump to solution
03-18-2014 02:28 AM
dgesridgesri
Occasional Contributor II
Greetings,

I have downloaded "PyScripter-v2.5.3-x64-Setup.ex" and I`m using the Add-in Manager to add a command on a toolbar inside ArcMap 10.1...

I succeeded in adding the toolbar and the command, however I need to show a Messagebox at the On_Click event of the command and I`m not able to do that...This is my code below:

import arcpy import pythonaddins  class ButtonClass1(object):     def __init__(self):         self.enabled = True         self.checked = False     def onClick(self):         arcpy.AddMessage("TestMessg")         print("text")         pass


Please help!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Arfa,

You can use the MessageBox function.  See the following link:

http://resources.arcgis.com/en/help/main/10.2/index.html#/The_pythonaddins_module/014p00000021000000...

Ex:

pythonaddins.MessageBox('Test Message', 'INFO', 0)

View solution in original post

0 Kudos
2 Replies
Zeke
by
Regular Contributor III
Try this:


import ctypes  # An included library with Python install. ctypes.windll.user32.MessageBoxA(0, "Your text", "Your title", 1)  Or define a function (Mbox) like so:
 
import ctypes  # An included library with Python install. def Mbox(title, text, style):     ctypes.windll.user32.MessageBoxA(0, text, title, style) Mbox('Your title', 'Your text', 1)  Note the styles are as follows:
 
##  Styles: ##  0 : OK ##  1 : OK | Cancel ##  2 : Abort | Retry | Ignore ##  3 : Yes | No | Cancel ##  4 : Yes | No ##  5 : Retry | No  ##  6 : Cancel | Try Again | Continue


From Stack Overflow
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Arfa,

You can use the MessageBox function.  See the following link:

http://resources.arcgis.com/en/help/main/10.2/index.html#/The_pythonaddins_module/014p00000021000000...

Ex:

pythonaddins.MessageBox('Test Message', 'INFO', 0)

View solution in original post

0 Kudos