Select to view content in your preferred language

Python Add-in puzzler with menus on a toolbar

961
1
07-03-2013 11:30 AM
DavidAllen
Frequent Contributor
I created a Python add-in with the wizard. Then I created a toolbar with a couple of combo boxes and tools. Lastly, I added a menu to hold three buttons that will generate PDF maps that I call the print menu.

I've got the combo boxes initializing as enabled = False, then changing them to true after the user selects some features with the tools. All pretty nice.

I'd like to make the buttons on the print menu disabled until the combo boxes have accepted their value entries. But there's a problem.

If you try to set them to enabled with the combo box you get a message that the item doesn't exist. That's because those three items haven't been created or initialized yet.

The buttons in the print menu don't initialize until someone clicks the menu name on the toolbar. At that point, the three buttons are initialized and set to be disabled.

The menu items don't exist in the Python script that is user editable, so you can't control them there. They only exist in the config.xml file.

My question, then, is if there is a way to initialize the menu and its buttons when the toolbar initializes?
Tags (2)
1 Reply
JasonScheirer
Esri Alum
At the bottom of your add-in .py file you can pre-initialize them like this:

button1 = ButtonClass() # Assuming you have a button named button1 with class ButtonClass

This usually works fine.
0 Kudos