1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Extract a different method in the solverdialogs.

This commit is contained in:
Shlomi Fish 2016-11-10 13:31:17 +02:00
parent 66d91c872c
commit 970e37ffe6
2 changed files with 21 additions and 14 deletions

View file

@ -88,11 +88,7 @@ class SolverDialog(BaseSolverDialog, MfxDialog):
self.games[name] = id
gamenames.sort()
self.gamenames = gamenames
cb = PysolCombo(frame, values=tuple(gamenames),
selectcommand=self.gameSelected,
state='readonly', width=40)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
self.games_var = cb
self.games_var = self._createGamesVar(frame, row)
#
row += 1
@ -168,6 +164,13 @@ class SolverDialog(BaseSolverDialog, MfxDialog):
self.connectGame(self.app.game)
self.mainloop(focus, kw.timeout, transient=False)
def _createGamesVar(self, frame, row):
cb = PysolCombo(frame, values=tuple(self.gamenames),
selectcommand=self.gameSelected,
state='readonly', width=40)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
return cb
def _createPresetVar(self, frame, row):
cb = PysolCombo(frame, values=tuple(self.presets), state='readonly')
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)

View file

@ -86,15 +86,7 @@ class SolverDialog(BaseSolverDialog, MfxDialog):
self.games[name] = id
gamenames.sort()
self.gamenames = gamenames
self.games_var = var = Tkinter.StringVar()
om = Tkinter.OptionMenu(frame, var, command=self.gameSelected,
*gamenames)
om.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
n = len(gamenames)
cb_max = int(self.top.winfo_screenheight()/23)
cb_max = n / (n/cb_max+1)
for i in xrange(cb_max, n, cb_max):
om['menu'].entryconfig(i, columnbreak=True)
self.games_var = self._createGamesVar(frame, row)
#
row += 1
@ -170,6 +162,18 @@ class SolverDialog(BaseSolverDialog, MfxDialog):
self.connectGame(self.app.game)
self.mainloop(focus, kw.timeout, transient=False)
def _createGamesVar(self, frame, row):
var = Tkinter.StringVar()
om = Tkinter.OptionMenu(frame, var, command=self.gameSelected,
*(self.gamenames))
om.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
n = len(gamenames)
cb_max = int(self.top.winfo_screenheight()/23)
cb_max = n / (n/cb_max+1)
for i in xrange(cb_max, n, cb_max):
om['menu'].entryconfig(i, columnbreak=True)
return var
def _createPresetVar(self, frame, row):
var = Tkinter.StringVar()
var.set('none')