6

I've got an add-in with a combo box and want to refresh the list in the combo box after an event in one of the other tools in the same add-in toolbar.

Can I call the combo box somehow to refresh it outside of the object's onSelChange event?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Feb 20, 2013 at 4:37
2
  • Can I see your code solution please, I have the same problem. I need to link a couple of combos. thank you and best regards! Commented May 9, 2013 at 0:45
  • Welcome to GIS-SE! One thing though - this would make a good Comment on the previous Answer but is itself not an Answer to the Question. Commented May 9, 2013 at 1:23

1 Answer 1

3

Finally managed to sort this one out. I managed to do that by adding a method in the combo box class, initiated them in the button class (where I wanted to refresh the combo box from) and then called the methods from within the button class.

import arcpy
import pythonaddins
cboSetup1 = None
cboSetup2 = None
class btn1(object):
 """Implementation for Class_addin.button (Button)"""
 def __init__(self):
 self.enabled = True
 self.checked = False
 def onClick(self):
 combo1 = cbobox1()
 combo1.btnPopulate()
 combo2 = cbobox2()
 combo2.btnPopulate()
class cbobox1(object): 
 """Implementation for Class_addin.combobox (ComboBox)"""
 def __init__(self):
 self.editable = True
 self.enabled = True
 self.dropdownWidth = 'WWWWWW'
 self.width = 'WWWWWW'
 def onFocus(self, focused):
 self.items = cboSetup1
 def btnPopulate(self):
 mxd = arcpy.mapping.MapDocument("CURRENT")
 self.items = []
 for layer in arcpy.mapping.ListLayers(mxd):
 self.items.append(layer.name)
 global cboSetup1
 cboSetup1 = self.items
class cbobox2(object):
 """Implementation for Class_addin.combobox_1 (ComboBox)"""
 def __init__(self):
 self.editable = True
 self.enabled = True
 self.dropdownWidth = 'WWWWWW'
 self.width = 'WWWWWW'
 def onFocus(self, focused):
 self.items = cboSetup2
 def btnPopulate(self):
 mxd = arcpy.mapping.MapDocument("CURRENT")
 self.items = []
 for layer in arcpy.mapping.ListLayers(mxd):
 self.items.append(layer.name)
 global cboSetup2
 cboSetup2 = self.items
answered Apr 22, 2013 at 1:12

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.