ionarawilson

I need to access in a python add-in, a python toolbox

Discussion created by ionarawilson on Oct 31, 2013
Latest reply on Nov 3, 2014 by moccand78
I need to access in a python add-in, a python toolbox I created. How can I do that? In my add-in everytime the second combobox changes the selection, it needs to refresh this python toolbox (pyt) I created.

import arcpy
import pythonaddins

class ComboBoxClass1(object):
    """Implementation for Comboboxes_addin.combobox (ComboBox)"""
    def __init__(self):
        self.items = ["Forestry", "OW", "Urban", "Fire", "ED/PR", "PD", "Media"]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWWWWW'
        self.width = 'WWWWWWWWWWWW'
    def onSelChange(self, selection):
      if selection == "Forestry":

                combobox_1.items = ["SP", "SPR", "MP", "AR", "ARO", "ATF", "ATN", "ACF", "TT", "RC", "RV", "AIR", "AP", "FHS", "FSU", "BMP"]
                combobox_1.value = combobox_1.items[0]
                combobox_1.refresh()
      elif selection == "OW":

                 combobox_1.items = ["AOS", "AO", "AIO", "PO", "TGO", "TRO"]
                 combobox_1.value = combobox_1.items[0]
                 combobox_1.refresh()
    def onEditChange(self, text):
        itemsarray = [" ", "Forestry", "OW", "Urban", "Fire", "ED/PR", "PD", "Media"]

        if text not in itemsarray:

            combobox_1.items = [""]
            combobox_1.value = combobox_1.items[0]
            combobox_1.refresh()
            pythonaddins.MessageBox("Please use only the items listed in the dropdown", "Warning", 0)
            combobox.value = " "
    def onFocus(self, focused):
        pass
    def onEnter(self):
        pass
    def refresh(self):
        pass

class ComboBoxClass2(object):
    """Implementation for Comboboxes_addin.combobox_1 (ComboBox)"""
    def __init__(self):
        self.items = [" ", " ", "", " ", "", "", "", "", "", "", "", "", "", "", "", ""]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWW'
        self.width = 'WWWWWW'
        self.refresh()
    def onSelChange(self, selection):
        self.refresh()
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):
         self.refresh()
    def onEnter(self):
        pass
    def refresh(self):
        pass

Outcomes