def __init__(self, options=[[]], padding=2, on_select=None ): #~ menu_options = self._make_options(options) GridLayout.__init__(self, options, padding=padding) self.on_select = on_select self.selected = None self.options = {} for row in options: for option in row: self.options[option.id] = option if option is not None: option.palette = self if options[0][0] is not None: self.select(options[0][0].id)
def __init__(self, options=[[]], padding=2, on_select=None, initialSelection=None): # ~ menu_options = self._make_options(options) GridLayout.__init__(self, options, padding=padding) self.on_select = on_select self.selected = None self.options = {} for row in options: for option in row: self.options[option.id] = option if option is not None: option.palette = self if initialSelection: self.selected = self.options[initialSelection] self.selected.select()