diff options
author | emkael <emkael@tlen.pl> | 2019-06-02 23:42:38 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-02 23:42:38 +0200 |
commit | d6692ee021a2c8c2b73b327aefaf43e139346e9c (patch) | |
tree | af7e0d2a1df9c406d121d9b032c927499f6a2192 /jfr_playoff/gui/tabs.py | |
parent | fe24609295876943391e572d3ec7a48f3f962e75 (diff) |
Providing Teamy database list on DB settings change
Diffstat (limited to 'jfr_playoff/gui/tabs.py')
-rw-r--r-- | jfr_playoff/gui/tabs.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py index 2d96ce7..7cb908a 100644 --- a/jfr_playoff/gui/tabs.py +++ b/jfr_playoff/gui/tabs.py @@ -134,7 +134,9 @@ class TeamsTab(PlayoffTab): if dbConfig is not None: config['database'] = dbConfig data = PlayoffData() - self._teamList = data.fetch_team_list(config['teams'], dbConfig) + self._teamList = data.fetch_team_list( + config['teams'], + PlayoffDB(dbConfig) if dbConfig is not None else None) self.winfo_toplevel().event_generate( '<<TeamListChanged>>', when='tail') @@ -166,6 +168,26 @@ class NetworkTab(PlayoffTab): def title(self): return 'Sieć' + def _onDBSettingsChange(self, event): + if self.dbFetchTimer is not None: + self.after_cancel(self.dbFetchTimer) + self.dbFetchTimer = self.after(1500, self._fetchDBList) + + def _fetchDBList(self): + self._dbList = [] + try: + db = PlayoffDB(self.getDB()) + for row in db.fetch_all( + 'information_schema', + 'SELECT TABLE_SCHEMA FROM information_schema.COLUMNS WHERE TABLE_NAME = "admin" AND COLUMN_NAME = "teamcnt" ORDER BY TABLE_SCHEMA;', {}): + self._dbList.append(row[0]) + except Exception as e: + pass + self.winfo_toplevel().event_generate('<<DBListChanged>>', when='tail') + + def getDBList(self): + return self._dbList + def getDB(self): return self.mysqlFrame.getConfig() @@ -185,6 +207,11 @@ class NetworkTab(PlayoffTab): self.remoteFrame = RemoteConfigurationFrame(container, vertical=True) self.remoteFrame.pack(side=tk.TOP, fill=tk.BOTH, expand=True) + self._dbList = [] + self.dbFetchTimer = None + self.winfo_toplevel().bind( + '<<DBSettingsChanged>>', self._onDBSettingsChange, add='+') + class VisualTab(PlayoffTab): @property def title(self): |