def refresh_collection(self, collection): print 'Asked to refresh collection', collection matching_screens = filter(lambda j: j == ('Collection ' + collection), self.screen_names) if len(matching_screens) > 0: scr = self.get_screen(matching_screens[0]) collection_model = list(Collection.select().where(Collection.name == collection))[0] gc = scr.children[0] games = get_games_in(collection_model) args_converter = games_args_converter list_adapter = ListAdapter(data=games, args_converter = args_converter, selection_mode = 'single', allow_empty_selection=True, cls=GameChooserButton, ) gc.gameslist.adapter = list_adapter self.refresh_collections_index()
def view_or_open_collection(self, selection, goto=True): print "asked to view_or_open", selection if len(selection) == 0: return False collection_name = selection[0].colname if self.has_screen("Collection " + collection_name): print "screen already exists", collection_name print "supposed to refresh", self.collections_to_refresh matching_refresh = filter(lambda j: j.name == collection_name, self.collections_to_refresh) if len(matching_refresh) > 0: self.refresh_collection(matching_refresh[0]) self.collections_to_refresh.remove(matching_refresh[0]) self.current = "Collection " + collection_name else: collections = App.get_running_app().collections collection = selection[0].collection screenname = "Collection " + collection.name games = get_games_in(collection) args_converter = games_args_converter list_adapter = ListAdapter( data=games, args_converter=args_converter, selection_mode="single", allow_empty_selection=True, cls=GameChooserButton, ) gc = StandaloneGameChooser(managedby=self, collection=collection) gc.gameslist.adapter = list_adapter print "made gc and set adapter" # print 'games are',games # print 'gameinfos are', map(lambda j: j.gameinfo,games) s = Screen(name=screenname) s.add_widget(gc) self.add_widget(s) if goto: self.switch_and_set_back(s.name)
def view_or_open_collection(self, selection, goto=True): print 'asked to view_or_open', selection if len(selection) == 0: return False collection_name = selection[0].colname if self.has_screen('Collection ' + collection_name): print 'screen already exists', collection_name print 'supposed to refresh', self.collections_to_refresh matching_refresh = filter(lambda j: j == collection_name, self.collections_to_refresh) if len(matching_refresh) > 0: self.refresh_collection(matching_refresh[0]) self.collections_to_refresh.remove(matching_refresh[0]) self.current = 'Collection ' + collection_name else: collections = App.get_running_app().collections collection = selection[0].collection screenname = 'Collection ' + collection.name games = get_games_in(collection) args_converter = games_args_converter list_adapter = ListAdapter(data=games, args_converter = args_converter, selection_mode = 'single', allow_empty_selection=True, cls=GameChooserButton, ) gc = StandaloneGameChooser(managedby=self, collection=collection) gc.gameslist.adapter = list_adapter print 'made gc and set adapter' #print 'games are', games #print 'gameinfos are', map(lambda j: j.gameinfo, games) s = Screen(name=screenname) s.add_widget(gc) self.add_widget(s) if goto: self.switch_and_set_back(s.name)