AnsweredAssumed Answered

How to dynamically add items into python addin Combobox from another addin combobox.

Question asked by surendrankn on Jan 23, 2018
Latest reply on Feb 9, 2018 by surendrankn

I have two combo boxes. I am trying to add items dynamically into the second combobox from the first combobox's "onSelChange(self, selection)" event.
due to some reason this is not working.

here is my sample code:

import arcpy
import pythonaddins
class ComboBoxClass1(object):
    def __init__(self):
        self.items = []
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWW'
        self.width = 'WWWWWW'
    def onSelChange(self, selection):
        pass
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):
        self.refresh()
        pass
    def onEnter(self):
        pass
    def refresh(self):
        self.refresh()
        pass

class ComboBoxClass2(object):

    def __init__(self):
        self.items = ["Location1","Location2","Location3"]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWWW'
        self.width = 'WWWWWWW'
        self.cb1= ComboBoxClass1()
    def onSelChange(self, selection):
        self.cb1.items.append(selection)
        self.cb1.refresh()
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):
      # When the combo box has focus, update the combo box with the list of layer names.
      pass
    def onEnter(self):
        pass
    def refresh(self):
        self.refresh()
        pass

Outcomes