summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-01 00:47:58 +0200
committeremkael <emkael@tlen.pl>2019-06-01 00:47:58 +0200
commit596efa60514452c1e29e0f5a9c89078a49a5b4dc (patch)
tree9a11de9dfca5f440dad53eeb82e2730fcac90fba /jfr_playoff
parent550e9c61dd0520507305ac35270561eee4db029b (diff)
Grace period and caching in team list refresh events
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/gui/tabs.py17
1 files 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(
'<<TeamSettingsChanged>>', self.onTeamSettingsChange, add='+')
def onTeamSettingsChange(self, event):
- self.winfo_toplevel().event_generate(
- '<<TeamListChanged>>', 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(
+ '<<TeamListChanged>>', when='tail')
+
+ def getTeams(self):
+ return self._teamList
def collectConfig(self):
config = {