From 596efa60514452c1e29e0f5a9c89078a49a5b4dc Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 1 Jun 2019 00:47:58 +0200 Subject: Grace period and caching in team list refresh events --- jfr_playoff/gui/tabs.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py index 64cc014..c81a14a 100644 --- a/jfr_playoff/gui/tabs.py +++ b/jfr_playoff/gui/tabs.py @@ -116,20 +116,29 @@ class TeamsTab(PlayoffTab): container.rowconfigure(0, weight=2) container.rowconfigure(2, weight=1) + self._teamList = [] + self._teamListFetcher = None + self.winfo_toplevel().bind( '<>', self.onTeamSettingsChange, add='+') def onTeamSettingsChange(self, event): - self.winfo_toplevel().event_generate( - '<>', when='tail') + if self._teamListFetcher is not None: + self.after_cancel(self._teamListFetcher) + self._teamListFetcher = self.after(500, self._fetchTeamList) - def getTeams(self): + def _fetchTeamList(self): config = self.collectConfig() dbConfig = self.winfo_toplevel().getDbConfig() if dbConfig is not None: config['database'] = dbConfig data = PlayoffData() - return data.fetch_team_list(config['teams'], dbConfig) + self._teamList = data.fetch_team_list(config['teams'], dbConfig) + self.winfo_toplevel().event_generate( + '<>', when='tail') + + def getTeams(self): + return self._teamList def collectConfig(self): config = { -- cgit v1.2.3