3

I've got a weird problem. My addin throws problems intermittently where it doesn't recognize buttons or tools when I try to toggle the visibility in my code. It seems as though the objects aren't instantiated as trying to toggle them works after I try to interact with them. What is the problem and how do I begin to debug it? My code is far too long to post but if there's something I can provide to help can you let me know?

Here's a scenario:

User starts Arc and clicks a button. The button tries to enable another button with:

anotherButton.enabled = False

Arc throws an error:

global variable "anotherButton" not defined.

User clicks on "anotherButton" and then tries the first button again. This time the command executes and "anotherButton" is disabled.

asked Nov 18, 2013 at 15:56

1 Answer 1

3

The add-in framework usually won't create the objects until it needs them. I have a solution in this Esri forums thread: create them yourself at load time, so you'd have something like

anotherButton = anotherButtonClass()

at the bottom of your add-in's main .py file to make sure it's around.

answered Nov 18, 2013 at 17:23
3
  • wow! Thank you. I can't tell you how many hours I scoured the internet looking for this solution. Commented Nov 18, 2013 at 17:43
  • @Jason Is this behavior similar to the "onDemand" property of .NET add-in types? I would generally set "onDemand" to false to avoid such problems. Commented Nov 19, 2013 at 0:22
  • 1
    Exactly the same. The Python add-in framework shares a lot of the same code with the .Net add-in framework. Commented Nov 19, 2013 at 1:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.