gui/controls/listbox.py
def _set_items(self, a_iter):
        "Clear and set the strings (and data if any) in the control from a list"

        self._items_dict = {}
        if not a_iter:
            string_list = []
            data_list = []
        elif not isinstance(a_iter, (tuple, list, dict)):
            raise ValueError("items must be an iterable")
        elif isinstance(a_iter, dict):
            # use keys as data, values as label strings
            self._items_dict = a_iter
            string_list = a_iter.values()
            data_list = a_iter.keys()
        elif isinstance(a_iter[0], (tuple, list)) and len(a_iter[0]) == 2:
            # like the dict, but ordered
            self._items_dict = dict(a_iter)
            data_list, string_list = zip(*a_iter)
        else:
            # use the same strings as data
            string_list = a_iter
            data_list = a_iter

        # set the strings
        self.wx_obj.SetItems(string_list)
        # set the associated data
        for i, data in enumerate(data_list):
            self.set_data(i, data)
def _set_items(self, a_iter):
        "Clear and set the strings (and data if any) in the control from a list"

        self._items_dict = {}
        if not a_iter:
            string_list = []
            data_list = []
        elif not isinstance(a_iter, (tuple, list, dict)):
            raise ValueError("items must be an iterable")
        elif isinstance(a_iter, dict):
            # use keys as data, values as label strings
            self._items_dict = a_iter
            string_list = a_iter.values()
            data_list = a_iter.keys()
        elif isinstance(a_iter[0], (tuple, list)) and len(a_iter[0]) == 2:
            # like the dict, but ordered
            self._items_dict = dict(a_iter)
            data_list, string_list = zip(*a_iter)
        else:
            # use the same strings as data
            string_list = a_iter
            data_list = a_iter

        # set the strings
        self.wx_obj.SetItems(string_list)
        # set the associated data
        for i, data in enumerate(data_list):
            self.set_data(i, data)
def _set_items ( self , a_iter ) : self . _items_dict = { } if not a_iter : string_list = [ ] data_list = [ ] elif not isinstance ( a_iter , ( tuple , list , dict ) ) : raise ValueError ( "items must be an iterable" ) elif isinstance ( a_iter , dict ) : # use keys as data, values as label strings
 self . _items_dict = a_iter string_list = a_iter . values ( ) data_list = a_iter . keys ( ) elif isinstance ( a_iter [ 0 ] , ( tuple , list ) ) and len ( a_iter [ 0 ] ) == 2 : # like the dict, but ordered
 self . _items_dict = dict ( a_iter ) data_list , string_list = zip ( * a_iter ) else : # use the same strings as data
 string_list = a_iter data_list = a_iter # set the strings
 self . wx_obj . SetItems ( string_list ) # set the associated data
 for i , data in enumerate ( data_list ) : self . set_data ( i , data )
Clear and set the strings (and data if any) in the control from a list
Clear and set the strings ( and data if any ) in the control from a list