Currently, we have:
OpenDialog
SaveDialog
GPToolDialog
MessageBox
But there's no way to actually get user input. Why is this? Does ESRI plan on eventually providing a way to get user input?
What are the input requirements?
One solution is to create a new tool in a Toolbox.tbx and setup input parameters. Then you can open/popup this as a UI with:
pythonaddins.GPToolDialog(r'<path>\<toolboxname.tbx>', '<tool name>')
Here's how it might look hooked into an add-in with a button tool:
class ButtonClass_CreateSHP(object): """Implementation for my_addin.button_1 (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): pythonaddins.GPToolDialog(r'<path>\<toolboxname.tbx>', 'CreateShapefile')
Do you have it in a Toolbox? It's easy to create a Python addin from a tools box that will have a user interface. For what it's worth, I have some steps listed in a power point Python add-ins vs. .NET add-ins?
And there is a tech session Python Add-ins: Tips and Tricks that might be worth checking out.
Yeah, I've thought about that. I just see it as kind of a clunky, unattractive way of doing it. I'd be nice to just have a dialog box that the user could enter a value into- it seems simple enough.
One example is that I'd like to have a button that when clicked takes an OID of a specific layer for input, and zooms to that feature based on the OID entered. Easy enough to do, but the whole user input part is missing.
I think you can accomplish this with the Tool Validator and set the input parameter when you launch the tool:
pythonaddins.GPToolDialog(r'<path>\<toolboxname.tbx>', '<tool name>', '<arg1>', '<arg2')
Right. I guess my main point is that I'd like to have a way of getting user input without needing to use an existing toolbox.
Check out ArcMap and Python: Closing the VBA Gap | Esri Video
Using wxPython as described in this video works even if it isn't officially supported by esri.
Rebecca, Jason's presentation is still just a bunch of blank screens with titles..I suspect some iThingy problem. There are still a bunch of posts on that thread...Do you have a link that can be read with all content?
Dan, your right. I looked at it a while ago and just copied the link. I'll edit my post.
But be cautious. As per my other post about Tkinter, wxPython GUI's in Python add-ins can randomly cause ArcMap to crash. A very simply GUI may not experience the problem, but I would not trust it. My experience with wxPython and several other Python GUIs in a Python add-in all had the same problem (by my GUI was somewhat more complicated).
I then found that other people had concluded that non-ArcMap GUIs in Python addins are incompatible with ArcMap and likely to cause it to crash.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.