Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

How can you sort a set of unique values? Arcpy addin

$
0
0
I have tried many ways to sort that work, but then I can't get unique values. The following works to return unique values, it would seem I need to add something to the onFocus part to make it work. any suggestions?
Code:

Rng = []
for row in arcpy.SearchCursor("X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData\Townships"):
    Rng.append(row.RNG_NUMC)
   
class ComboBoxClass7(object): #Collect Range from list of unique values gathered from the layer
    """Implementation for MTR_addin.combobox_3 (ComboBox)"""
    def __init__(self):
        self.value = "000"
        self.items = (Rng)
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWW'
        self.width = 'WWWW'
    def onSelChange(self, selection):
        self.sel = selection 
    def onEditChange(self, text):
        pass
    def onFocus(self, focused):#show only unique values
        if focused:
            values = (Rng)
            uniqueValues = set(values)
            self.items = []
            for uniqueValue in uniqueValues:
                self.items.append(uniqueValue)


Viewing all articles
Browse latest Browse all 2485

Trending Articles