Select to view content in your preferred language

How can I display a custom dialog box in ArcGis Pro using Python?

1472
2
Jump to solution
06-24-2022 09:44 AM
Labels (2)
LuisEduardoPerezGraterol
Emerging Contributor

Hello

In ArcGis Desktop I can create a dialog box using Python and Tkinter.

Can I do something similar in ArcGis Pro?

Apparently I can't use Tkinter in ArcGis Pro, I can't import it, but is there an equivalent alternative?

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Alum

ArcGIS Pro uses Python 3.X (ArcMap uses 2.7.X I think). TKinter was renamed to tkinter.

JohannesLindner_0-1656089785897.png

You could try using that. In my experience, Pro and Python guis don't play very well together. Save your work before you try, there's a good chance Pro will crash or freeze.

I belive the way to do something like that would be writing your own AddIn.

But that seems like a lot of hassle for a simple dialog window.

For a simple message box, something like this could suffice:

import webbrowser

def open_dialog_box(message):
    path = "H:/dialog_box.txt"  # some location you have write access to
    with open(path, "w") as f:
        f.write(message)
    webbrowser.open(path)

open_dialog_box("Hey there!")

 

JohannesLindner_1-1656090262712.png

 


Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Alum

ArcGIS Pro uses Python 3.X (ArcMap uses 2.7.X I think). TKinter was renamed to tkinter.

JohannesLindner_0-1656089785897.png

You could try using that. In my experience, Pro and Python guis don't play very well together. Save your work before you try, there's a good chance Pro will crash or freeze.

I belive the way to do something like that would be writing your own AddIn.

But that seems like a lot of hassle for a simple dialog window.

For a simple message box, something like this could suffice:

import webbrowser

def open_dialog_box(message):
    path = "H:/dialog_box.txt"  # some location you have write access to
    with open(path, "w") as f:
        f.write(message)
    webbrowser.open(path)

open_dialog_box("Hey there!")

 

JohannesLindner_1-1656090262712.png

 


Have a great day!
Johannes
0 Kudos
LuisEduardoPerezGraterol
Emerging Contributor

Thanks, this works!!!
I have to study the addins

0 Kudos