Skip to main content
edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to dynamically add Dynamically adding items into one python addin Combobox from another addin combobox?

edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
added 181 characters in body
Source Link
aldo_tapia
  • 13.8k
  • 5
  • 32
  • 58

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

hereHere is my sample code:

import arcpy import pythonaddins

class ComboBoxClass1(object): """Implementation for TestCombo_addin.combobox (ComboBox)""" def init(self): self.items = ["cb1item1", "cb1item2"] self.editable = True self.enabled = True self.dropdownWidth = 'WWWWWW' self.width = 'WWWWWW' self.cb2=ComboBoxClass2()

import arcpy
import pythonaddins

class ComboBoxClass1(object):
    """Implementation for TestCombo_addin.combobox (ComboBox)"""
    def __init__(self):
        self.items = ["cb1item1", "cb1item2"]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWW'
        self.width = 'WWWWWW'
        self.cb2=ComboBoxClass2()

    def onSelChange(self, selection):
        pythonaddins.MessageBox(selection,"Message",0)
        self.cb2.items.append(selection)
        self.cb2.refresh()
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):
        pass
    def onEnter(self):
        pass
    def refresh(self):
        pass

class ComboBoxClass2(object): """Implementation for TestCombo_addin.combobox_1 (ComboBox)""" def init(self): self.items = ["cb2item1", "cb2item2"] self.editable = True self.enabled = True self.dropdownWidth = 'WWWWWW' self.width = 'WWWWWW'


class ComboBoxClass2(object):
    """Implementation for TestCombo_addin.combobox_1 (ComboBox)"""
    def __init__(self):
        self.items = ["cb2item1", "cb2item2"]
        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):
        pass
    def onEnter(self):
        pass
    def refresh(self):
        pass

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): """Implementation for TestCombo_addin.combobox (ComboBox)""" def init(self): self.items = ["cb1item1", "cb1item2"] self.editable = True self.enabled = True self.dropdownWidth = 'WWWWWW' self.width = 'WWWWWW' self.cb2=ComboBoxClass2()

def onSelChange(self, selection):
    pythonaddins.MessageBox(selection,"Message",0)
    self.cb2.items.append(selection)
    self.cb2.refresh()
def onEditChange(self, text):
    pass
def onFocus(self, focused):
    pass
def onEnter(self):
    pass
def refresh(self):
    pass

class ComboBoxClass2(object): """Implementation for TestCombo_addin.combobox_1 (ComboBox)""" def init(self): self.items = ["cb2item1", "cb2item2"] 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):
    pass
def onEnter(self):
    pass
def refresh(self):
    pass

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):
    """Implementation for TestCombo_addin.combobox (ComboBox)"""
    def __init__(self):
        self.items = ["cb1item1", "cb1item2"]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWW'
        self.width = 'WWWWWW'
        self.cb2=ComboBoxClass2()

    def onSelChange(self, selection):
        pythonaddins.MessageBox(selection,"Message",0)
        self.cb2.items.append(selection)
        self.cb2.refresh()
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):
        pass
    def onEnter(self):
        pass
    def refresh(self):
        pass

class ComboBoxClass2(object):
    """Implementation for TestCombo_addin.combobox_1 (ComboBox)"""
    def __init__(self):
        self.items = ["cb2item1", "cb2item2"]
        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):
        pass
    def onEnter(self):
        pass
    def refresh(self):
        pass
Source Link
sur
  • 1
  • 1
  • 3
Loading