def xdid_load(self, favcat_titles, favcat_selected, favnote, is_favorited): self.background_color = '#efeff4' l = ui.ListDataSource([]) l.items = [ {'title': list(i.values())[0], 'image': get_diamond(get_color_from_favcat(list(i.keys())[0])), 'accessory_type':'none'} for i in favcat_titles ] if is_favorited: l.items.append({ 'title': '取消收藏', 'image': 'iob:close_32', 'accessory_type':'none' }) self['tableview1'].height = 32*len(l.items) l.delete_enabled = False l.action = self.set_new_favcat_selected if is_favorited and favcat_selected: self['tableview1'].selected_row = (0, int(favcat_selected[6])) self.new_favcat_selected = favcat_selected self['tableview1'].scroll_enabled = False self['tableview1'].data_source = l self['tableview1'].delegate = l self['textview1'].text = favnote self['button_close'].action = self.close_view
def __init__(self, favcat, num, title, action): self.chosen = False self.width = 180 self.height = 38 self.favcat = favcat self.add_subview( ui.Label(frame=(3, 3, 50, 32), text=num, alignment=ui.ALIGN_RIGHT, font=('<system>', 16))) self.add_subview( ui.ImageView(frame=(53, 3, 24, 32), image=get_diamond(get_color_from_favcat(favcat)))) self.add_subview( ui.Label(frame=(77, 3, 100, 32), text=title, alignment=ui.ALIGN_LEFT, font=('<system>', 16))) self.add_subview(ui.Button(frame=(0, 0, 180, 38), action=action))