Skip to content

Commit 406220b

Browse files
committed
Add settings menu
* Add option to save time left in game notation. Closes #34 ![](https://i.imgur.com/Kc2VPJj.png)
1 parent 70cce7f commit 406220b

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

python_easy_chess_gui.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
['&Book', ['Set Book::book_set_k']],
206206
['&User', ['Set Name::user_name_k']],
207207
['Tools', ['PGN', ['Delete Player::delete_player_k']]],
208+
['&Settings', ['Game::settings_game_k']],
208209
['&Help', ['About']],
209210
]
210211

@@ -678,7 +679,7 @@ def __init__(self, theme, engine_config_file, user_config_file,
678679

679680
self.gui_theme = 'Reddit'
680681

681-
self.is_save_time_left = True
682+
self.is_save_time_left = False
682683
self.is_save_user_comment = True
683684

684685
def update_game(self, mc, user_move, time_left, user_comment):
@@ -3373,6 +3374,34 @@ def main_loop(self):
33733374
w.Close()
33743375
continue
33753376

3377+
# Mode: Neutral, Settings menu
3378+
if button == 'Game::settings_game_k':
3379+
win_title = 'Settings/Game'
3380+
layout = [
3381+
[sg.CBox('Save time left in game notation',
3382+
key='save_time_left_k',
3383+
default=self.is_save_time_left,
3384+
tooltip='[%clk h:mm:ss] will appear as\n' +
3385+
'move comment and is shown in move\n' +
3386+
'list and saved in pgn file.')],
3387+
[sg.OK(), sg.Cancel()],
3388+
]
3389+
3390+
w = sg.Window(win_title, layout, icon='Icon/pecg.ico')
3391+
window.Disable()
3392+
3393+
while True:
3394+
e, v = w.Read(timeout=10)
3395+
if e is None or e == 'Cancel':
3396+
break
3397+
if e == 'OK':
3398+
self.is_save_time_left = v['save_time_left_k']
3399+
break
3400+
3401+
window.Enable()
3402+
w.Close()
3403+
continue
3404+
33763405
# Mode: Neutral, Change theme
33773406
if button in GUI_THEME:
33783407
self.gui_theme = button

0 commit comments

Comments
 (0)