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?
-
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!user17971– user179712013年05月09日 00:45:30 +00:00Commented 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.PolyGeo– PolyGeo ♦2013年05月09日 01:23:46 +00:00Commented May 9, 2013 at 1:23
1 Answer 1
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