From d60b7db704e9ae3916afbc75167adbb23678497c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 7 Jun 2019 13:10:18 +0200 Subject: DBSelectionField fetches DB list by itself --- jfr_playoff/gui/frames/match.py | 6 ------ jfr_playoff/gui/frames/team.py | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'jfr_playoff/gui') diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py index f393585..9c7dfc7 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -12,9 +12,6 @@ class SwissSettingsFrame(RepeatableFrame): SOURCE_LINK = 0 SOURCE_DB = 1 - def _onDBListChange(self, *args): - self.fetchDBField.setOptions(self.winfo_toplevel().getDBs()) - def _setPositionInfo(self, *args): tournamentFrom = getIntVal(self.setFrom, default=1) tournamentTo = min( @@ -55,8 +52,6 @@ class SwissSettingsFrame(RepeatableFrame): self.fetchDBField = DBSelectionField( self, self.fetchDB, self.fetchDB.get()) self.fetchDBField.grid(row=1, column=1, sticky=tk.W+tk.E) - self.winfo_toplevel().bind( - '<>', self._onDBListChange, add='+') (ttk.Radiobutton( self, text='Strona turnieju', variable=self.source, value=self.SOURCE_LINK)).grid( @@ -123,7 +118,6 @@ class SwissSettingsFrame(RepeatableFrame): (ttk.Separator(self, orient=tk.HORIZONTAL)).grid( row=9, column=0, columnspan=6, sticky=tk.E+tk.W) - self._onDBListChange() self._setFields() self._setPositionInfo() diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py index ada8f24..17636da 100644 --- a/jfr_playoff/gui/frames/team.py +++ b/jfr_playoff/gui/frames/team.py @@ -138,13 +138,21 @@ class DBSelectionField(ttk.Entry): self._variable = variable self._variable.set(value) self._optionDict = options if options is not None else [] - self.bind('', self._onPress) - self.bind('', self._onChange) self._matches = [] self._prevValue = None + self._setOptions() + self.bind('', self._onPress) + self.bind('', self._onChange) + self.winfo_toplevel().bind( + '<>', self._setOptions, add='+') - def setOptions(self, values): - self._optionDict = values + def _setOptions(self, *args): + try: + self._optionDict = self.winfo_toplevel().getDBs() + except: + # some stuff may not be available yet + # don't worry, the event will fire when it is + self._optionDict = [] def _onPress(self, event): if event.keysym == 'Tab': @@ -207,9 +215,6 @@ class TeamFetchSettingsFrame(GuiFrame): teams['max_teams'] = maxTeams return teams - def _onDBListChange(self, *args): - self.fetchDBField.setOptions(self.winfo_toplevel().getDBs()) - def _sourceChange(self, *args): self.fetchDBField.configure(state=tk.DISABLED) self.fetchLink.configure(state=tk.DISABLED) @@ -233,9 +238,6 @@ class TeamFetchSettingsFrame(GuiFrame): self.fetchDBField = DBSelectionField( self, self.fetchDB, self.fetchDB.get()) self.fetchDBField.grid(row=0, column=3, sticky=tk.W+tk.E) - self.winfo_toplevel().bind( - '<>', self._onDBListChange, add='+') - self.fetchDBField.setOptions([]) (ttk.Radiobutton( self, text='Strona wyników', -- cgit v1.2.3