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

Add persistence for solver show progress.

See https://github.com/shlomif/PySolFC/issues/38 :

<<<
Currently the solver dialog (Assist → Solver when playing Freecell or
other supported games) does not remember its "Preset" , "Max Iterations"
and "Show Progress" settings - either across sessions of PySol or even
after closing and invoking it again. It should remember those but note
that it should not remember the "Game" setting because one can switch to
a different game.
>>>
This commit is contained in:
Shlomi Fish 2017-08-25 22:28:25 +03:00
parent dbdd0f392c
commit 1dec576b1a
2 changed files with 9 additions and 2 deletions

View file

@ -111,6 +111,7 @@ favorite_gameid = int_list
visible_buttons = string_list
translate_game_names = boolean
solver_presets = string_list
solver_show_progress = boolean
[sound_samples]
move = boolean
@ -244,6 +245,7 @@ class Options:
('tabletile_name', 'str'),
('translate_game_names', 'bool'),
('solver_presets', 'list'),
('solver_show_progress', 'bool'),
# ('toolbar_vars', 'list'),
# ('recent_gameid', 'list'),
# ('favorite_gameid', 'list'),
@ -410,6 +412,7 @@ class Options:
'video-editing',
'yellow-brick-road',
]
self.solver_show_progress = True
def setDefaults(self, top=None):
WIN_SYSTEM = pysollib.settings.WIN_SYSTEM

View file

@ -6,6 +6,9 @@ from pysollib.settings import TITLE
class BaseSolverDialog:
def _ToggleShowProgressButton(self, *args):
self.app.opt.solver_show_progress = self.progress_var.get()
def __init__(self, parent, app, **kw):
self.parent = parent
self.app = app
@ -60,9 +63,10 @@ class BaseSolverDialog:
#
row += 1
self.progress_var = tkinter.BooleanVar()
self.progress_var.set(True)
self.progress_var.set(self.app.opt.solver_show_progress)
w = self._createShowProgressButton(frame)
w.grid(row=row, column=0, columnspan=2, sticky='ew', padx=2, pady=2)
w.config(command=self._ToggleShowProgressButton)
#
label_frame = self._calcToolkit().LabelFrame(
@ -151,7 +155,7 @@ class BaseSolverDialog:
game.solver = solver
preset = self.preset_var.get()
max_iters = self.max_iters_var.get()
progress = self.progress_var.get()
progress = self.app.opt.solver_show_progress
solver.config(preset=preset, max_iters=max_iters, progress=progress)
solver.computeHints()
hints_len = len(solver.hints)-1