Select to view content in your preferred language

Dynamic Items for Python Add In Wizard Combo Box

3794
1
05-03-2012 07:34 AM
LaurenMarie
New Contributor
Hi there,

I am pretty new to python, and I'm sure I am getting a little ahead of myself by attempting to put a combo box script together, but here is my question:

I'm attempting to use the Python Add In Wizard in 10.1 to create a combo box, and I'd like to add a list of dynamic items to the dropdown.

So, I understand I'm supposed to delete the self.item = ["item1", "item2"] under def __init__(self):

but my question is this: which function would I set my dynamic item script to.  (According to the properties of the Combo Box class, I cannot place it under def __init__(self):....

The Python Add In Wizard creates it's own script which you are supposed to edit, so the other functions it provides are:

__init__(self)
onSelChange(self, selection)
onEditChange(self, text)
onFocus(self, focused)
onEnter(self)
Refresh(self)

Not sure if this makes much sense, but if it DOES make sense, then any help would be appreciated!

Thanks.
Tags (2)
0 Kudos
1 Reply
NobbirAhmed
Esri Alum
If you haven't figured it out or haven't received any response yet:

There is an example in the add-in help topic:
Creating an add-in combo box

This code in that examples populates the combo box when it gets the focus:

self.items = []
for layer in layers:
    self.items.append(layer.name)


Later, in any other method of the combo box (or of any other control - button/tool) if you want to add more item to the items list, use append to do so. To set a value in the current display you can use value property:

combobox_id.value = "new item"
combox_id.refresh()
0 Kudos