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/frames | |
parent | fe24609295876943391e572d3ec7a48f3f962e75 (diff) |
Providing Teamy database list on DB settings change
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r-- | jfr_playoff/gui/frames/network.py | 8 | ||||
-rw-r--r-- | jfr_playoff/gui/frames/team.py | 23 |
2 files changed, 29 insertions, 2 deletions
diff --git a/jfr_playoff/gui/frames/network.py b/jfr_playoff/gui/frames/network.py index 249cb1c..961ee21 100644 --- a/jfr_playoff/gui/frames/network.py +++ b/jfr_playoff/gui/frames/network.py @@ -43,24 +43,31 @@ class MySQLConfigurationFrame(tk.Frame): if self.dbError is not None: tkmb.showerror('Błąd połączenia z bazą danych', self.dbError) + def _changeNotify(self, *args): + self.winfo_toplevel().event_generate( + '<<DBSettingsChanged>>', when='tail') + def renderContent(self, container): (ttk.Label(container, text='Ustawienia MySQL')).grid( row=0, column=0, columnspan=4, sticky=tk.E+tk.W) (ttk.Label(container, text='Host:')).grid( row=1, column=0, sticky=tk.E) self.host = tk.StringVar() + self.host.trace('w', self._changeNotify) (ttk.Entry(container, textvariable=self.host)).grid( row=1, column=1, sticky=tk.E+tk.W) (ttk.Label(container, text='Port:')).grid( row=1, column=2, sticky=tk.E) self.port = tk.StringVar() self.port.set(3306) + self.port.trace('w', self._changeNotify) (tk.Spinbox( container, textvariable=self.port, width=5, from_=0, to=65535)).grid(row=1, column=3, sticky=tk.W) (ttk.Label(container, text='Użytkownik:')).grid( row=2, column=0, sticky=tk.E) self.user = tk.StringVar() + self.user.trace('w', self._changeNotify) (ttk.Entry(container, textvariable=self.user)).grid( row=2, column=1, sticky=tk.E+tk.W) (ttk.Button( @@ -73,6 +80,7 @@ class MySQLConfigurationFrame(tk.Frame): (ttk.Label(container, text='Hasło:')).grid( row=3, column=0, sticky=tk.E) self.pass_ = tk.StringVar() + self.pass_.trace('w', self._changeNotify) (ttk.Entry(container, textvariable=self.pass_, show='*')).grid( row=3, column=1, sticky=tk.E+tk.W) diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py index 78b2be0..e7eb83d 100644 --- a/jfr_playoff/gui/frames/team.py +++ b/jfr_playoff/gui/frames/team.py @@ -139,19 +139,38 @@ class TeamFetchSettingsFrame(tk.Frame): teams['max_teams'] = maxTeams return teams + def _createDBList(self, values): + self.fetchDBField = ttk.OptionMenu( + self, self.fetchDB, *([''] + values)) + self.fetchDBField.grid(row=0, column=3, sticky=tk.W+tk.E) + + def _onDBListChange(self, *args): + self.fetchDBField.destroy() + self._createDBList(self.winfo_toplevel().getDBs()) + + def _sourceChange(self, *args): + self.fetchDBField.configure(state=tk.DISABLED) + self.fetchLink.configure(state=tk.DISABLED) + if self.fetchSource.get() == self.SOURCE_LINK: + self.fetchLink.configure(state=tk.NORMAL) + elif self.fetchSource.get() == self.SOURCE_DB: + self.fetchDBField.configure(state=tk.NORMAL) + def renderContent(self): (ttk.Label(self, text=' ')).grid(row=0, column=0, rowspan=2) self.fetchSource = tk.IntVar() self.fetchSource.set(self.SOURCE_LINK) + self.fetchSource.trace('w', self._sourceChange) (ttk.Radiobutton( self, text='Baza danych', variable=self.fetchSource, value=self.SOURCE_DB)).grid( row=0, column=1, columnspan=2, sticky=tk.W) self.fetchDB = tk.StringVar() self.fetchDB.trace('w', self._changeNotify) - (ttk.OptionMenu(self, self.fetchDB, '')).grid( - row=0, column=3, sticky=tk.W+tk.E) + self._createDBList([]) + self.winfo_toplevel().bind( + '<<DBListChanged>>', self._onDBListChange, add='+') (ttk.Radiobutton( self, text='Strona wyników', |