summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/tabs.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-02 23:42:38 +0200
committeremkael <emkael@tlen.pl>2019-06-02 23:42:38 +0200
commitd6692ee021a2c8c2b73b327aefaf43e139346e9c (patch)
treeaf7e0d2a1df9c406d121d9b032c927499f6a2192 /jfr_playoff/gui/tabs.py
parentfe24609295876943391e572d3ec7a48f3f962e75 (diff)
Providing Teamy database list on DB settings change
Diffstat (limited to 'jfr_playoff/gui/tabs.py')
-rw-r--r--jfr_playoff/gui/tabs.py29
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):