Select to view content in your preferred language

Reorder Python Addin Elements without Rebuilding Entire Addin?

2750
2
Jump to solution
01-28-2013 04:58 AM
JohnDye
Deactivated User
Does anyone know of a way to reorder Python Addin elements built in the Addin Assistant without having to rebuild the entire thing?

Situation:
I built a couple of toolbars and toolpalettes, buttons, tools, ect.

I've been asked to insert a "Combo Box" drop down to control the tool all of the elements enabled state based on the user's combo box selection
ie.


[INDENT][/INDENT]if combo box = "Selection1", tool1, tool2 and tool3, self.enabled=true and tool4, tool5, tool6 self.enabled=false.

That's not the actual code, just a basic reference to give you an idea of what I mean.

So when I added the combo box into the addin, the stupid thing is at the end of the toolpalette and toolbar because of course, I created it after everything else. There doesn't appear to be a way to just drag and drop elements into the order you want them to appear in. I thought about maybe editing the config.xml but first of all, I don't know if that will actually solve the problem and secondly, I'd prefer not to delve into that and open pandora's box if there is a more elegant solution available.

I know I can hit customize in ArcMap and move it. But that customization won't reflect in the esriaddin file I distribute, so when others install it they will need to make that customization as well which...they shouldn't have to do.

Any ideas?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisFox3
Frequent Contributor
I spoke with John on this through e-mail, but thought I would post the answer here as well in case anyone in the future needs to know.

To change this you would need to modify the config.xml. Below is an example of the section of the config defining the toolbars. Inside the Toolbars tag are two toolbars. Defined with Toolbar2 are the items on that Toolbar. In this scenario I have a 2 buttons, followed by a tool and a combobox in that order.

<Toolbars>  <Toolbar caption="Toolbar2" category="Python Addin" id="TestAddin_addin.toolbar" showInitially="true">   <Items>    <Button refID="TestAddin_addin.button" />    <Button refID="TestAddin_addin.button_1" />    <Tool refID="TestAddin_addin.tool" />    <ComboBox refID="TestAddin_addin.combobox" />   </Items>  </Toolbar>                                   <Toolbar caption="Toolbar1" category="Python Addin" id="TestAddin_addin.toolbar_1" showInitially="true"><Items /></Toolbar> </Toolbars>


If I want to move the combox box to be the first item on the toolbar I would modify the xml to the following, with the ComboxBox defined first.

<Toolbars>  <Toolbar caption="Toolbar2" category="Python Addin" id="TestAddin_addin.toolbar" showInitially="true">   <Items>    <ComboBox refID="TestAddin_addin.combobox" />    <Button refID="TestAddin_addin.button" />    <Button refID="TestAddin_addin.button_1" />    <Tool refID="TestAddin_addin.tool" />   </Items>  </Toolbar>                                   <Toolbar caption="Toolbar1" category="Python Addin" id="TestAddin_addin.toolbar_1" showInitially="true"><Items /></Toolbar> </Toolbars>


I wouldn???t be too concerned with modifying the xml, just make a copy of the original first and keep it as a back-up in case anything goes wrong you can always roll back. At this time this is the only way to modify the order of elements on a toolbar after it has already been authored in the python add-in wizard.

View solution in original post

2 Replies
ChrisFox3
Frequent Contributor
I spoke with John on this through e-mail, but thought I would post the answer here as well in case anyone in the future needs to know.

To change this you would need to modify the config.xml. Below is an example of the section of the config defining the toolbars. Inside the Toolbars tag are two toolbars. Defined with Toolbar2 are the items on that Toolbar. In this scenario I have a 2 buttons, followed by a tool and a combobox in that order.

<Toolbars>  <Toolbar caption="Toolbar2" category="Python Addin" id="TestAddin_addin.toolbar" showInitially="true">   <Items>    <Button refID="TestAddin_addin.button" />    <Button refID="TestAddin_addin.button_1" />    <Tool refID="TestAddin_addin.tool" />    <ComboBox refID="TestAddin_addin.combobox" />   </Items>  </Toolbar>                                   <Toolbar caption="Toolbar1" category="Python Addin" id="TestAddin_addin.toolbar_1" showInitially="true"><Items /></Toolbar> </Toolbars>


If I want to move the combox box to be the first item on the toolbar I would modify the xml to the following, with the ComboxBox defined first.

<Toolbars>  <Toolbar caption="Toolbar2" category="Python Addin" id="TestAddin_addin.toolbar" showInitially="true">   <Items>    <ComboBox refID="TestAddin_addin.combobox" />    <Button refID="TestAddin_addin.button" />    <Button refID="TestAddin_addin.button_1" />    <Tool refID="TestAddin_addin.tool" />   </Items>  </Toolbar>                                   <Toolbar caption="Toolbar1" category="Python Addin" id="TestAddin_addin.toolbar_1" showInitially="true"><Items /></Toolbar> </Toolbars>


I wouldn???t be too concerned with modifying the xml, just make a copy of the original first and keep it as a back-up in case anything goes wrong you can always roll back. At this time this is the only way to modify the order of elements on a toolbar after it has already been authored in the python add-in wizard.
JohnDye
Deactivated User
Thanks Chris,
Would you mind taking a look at this post if you have a few moments?

http://forums.arcgis.com/threads/78771-Use-Selection-of-one-Combobox-to-update-the-items-list-in-ano...
0 Kudos