python add-in combobox to show self.value when first loaded

833
2
02-04-2014 04:36 AM
JelmerOosthoek
New Contributor III
Using self.value it is possible to preset the value of the combo box (one of the values in the self.items list). But this value is not shown when the add-in is first loaded, you still see a blank combo box, even after self.refresh(). How can I show the selected value?

This is not the most important functionality, but I think it would make the add-in I'm working on more easily understood by users.
Tags (2)
0 Kudos
2 Replies
JasonScheirer
Occasional Contributor III
This combobox worked without issue for me:

# coding: utf-8
import arcpy
import pythonaddins

class ComboBoxClass1(object):
    """Implementation for Dropdown_addin.combobox (ComboBox)"""
    def __init__(self):
        self.value = "Hello"
        self.items = ["Hello", "Goodbye"]
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWW'
        self.width = 'WWWWWW'
0 Kudos
JelmerOosthoek
New Contributor III
Thanks! That did the trick! I needed to set self.enabled and self.editable to True.
0 Kudos