From fb10d2ae7856c9ba8e1a0426ce59a2a95569b32e Mon Sep 17 00:00:00 2001 From: DevilXD Date: Tue, 11 Jan 2022 11:58:52 +0100 Subject: [PATCH] Fix selecting next game --- gui.py | 18 ++++++++++-------- twitch.py | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gui.py b/gui.py index 69440d7..daf012b 100644 --- a/gui.py +++ b/gui.py @@ -294,16 +294,18 @@ class GameSelector: return first_game return self._games[self._selection] - def get_next_selection(self) -> Optional[Game]: + def select_next(self) -> Optional[Game]: current = self._list.curselection() if not current: return self.get_selection() - game_name = self._list.get(current[0]+1) - if game_name: - return self._games[game_name] - else: + next_idx = current[0]+1 + game_name = self._list.get(next_idx) + if not game_name: # this was the last game on the list return None + self._list.selection_set(next_idx) + self._selection = game_name + return self._games[game_name] class _BaseVars(TypedDict): @@ -856,9 +858,9 @@ if __name__ == "__main__": create_game(491115, "Paladins"), # create_game(460630, "Tom Clancy's Rainbow Six Siege"), ]) - gui.games.get_next_selection() - gui.games.get_next_selection() - gui.games.get_next_selection() + gui.games.select_next() + gui.games.select_next() + gui.games.select_next() # Channel list gui.channels.display(create_channel("PaladinsGame", 0, None, 0, 0)) channel = create_channel("Traitus", 1, None, 0, 0) diff --git a/twitch.py b/twitch.py index e8b2000..6bba8d6 100644 --- a/twitch.py +++ b/twitch.py @@ -262,7 +262,7 @@ class Twitch: break else: self.stop_watching() - selected_game = self.gui.games.get_next_selection() + selected_game = self.gui.games.select_next() if selected_game is None: self.gui.print("No suitable channel to watch.") # TODO: Figure out what to do here.