6060
6161
6262APP_NAME = 'Python Easy Chess GUI'
63- APP_VERSION = 'v1.6 '
63+ APP_VERSION = 'v1.7 '
6464BOX_TITLE = '{} {}' .format (APP_NAME , APP_VERSION )
6565
6666
67+ platform = sys .platform
68+
69+
70+ ico_path = {'win32' : {'pecg' : 'Icon/pecg.ico' , 'enemy' : 'Icon/enemy.ico' ,
71+ 'adviser' : 'Icon/adviser.ico' },
72+ 'linux' : {'pecg' : 'Icon/pecg.png' , 'enemy' : 'Icon/enemy.png' ,
73+ 'adviser' : 'Icon/adviser.png' },
74+ 'darwin' : {'pecg' : 'Icon/pecg.png' , 'enemy' : 'Icon/enemy.png' ,
75+ 'adviser' : 'Icon/adviser.png' }}
76+
77+
6778MIN_DEPTH = 1
6879MAX_DEPTH = 1000
6980MANAGED_UCI_OPTIONS = ['ponder' , 'uci_chess960' , 'multipv' , 'uci_analysemode' ,
@@ -731,7 +742,8 @@ def create_new_window(self, window, flip=False):
731742 layout ,
732743 default_button_element_size = (12 , 1 ),
733744 auto_size_buttons = False ,
734- location = (loc [0 ], loc [1 ]), icon = 'Icon/pecg.ico' )
745+ location = (loc [0 ], loc [1 ]),
746+ icon = ico_path [platform ]['pecg' ])
735747
736748 # Initialize White and black boxes
737749 while True :
@@ -1237,7 +1249,8 @@ def update_text_box(self, window, msg, is_hide):
12371249 sg .Popup ('Engine error, it sent a {} bestmove.\n ' .format (
12381250 best_move ) + 'Back to Neutral mode, it is better to '
12391251 'change engine {}.' .format (
1240- self .opp_id_name ), icon = 'Icon/pecg.ico' , title = BOX_TITLE )
1252+ self .opp_id_name ), icon = ico_path [platform ]['pecg' ],
1253+ title = BOX_TITLE )
12411254
12421255 return best_move
12431256
@@ -1460,7 +1473,7 @@ def select_promotion_piece(self, stm):
14601473 board_layout ,
14611474 default_button_element_size = (12 , 1 ),
14621475 auto_size_buttons = False ,
1463- icon = 'Icon/ pecg.ico' )
1476+ icon = ico_path [ platform ][ ' pecg' ] )
14641477
14651478 while True :
14661479 button , value = promo_window .Read (timeout = 0 )
@@ -1573,7 +1586,7 @@ def set_depth_limit(self):
15731586 user_depth = sg .PopupGetText (
15741587 'Current depth is {}\n \n Input depth [{} to {}]' .format (
15751588 self .max_depth , MIN_DEPTH , MAX_DEPTH ), title = BOX_TITLE ,
1576- icon = 'Icon/ pecg.ico' )
1589+ icon = ico_path [ platform ][ ' pecg' ] )
15771590
15781591 try :
15791592 user_depth = int (user_depth )
@@ -1806,7 +1819,8 @@ def play_game(self, window, engine_id_name, board):
18061819 self .adviser_id_name ) + \
18071820 'It is better to change this engine.\n ' +
18081821 'Change to Neutral mode first.' ,
1809- icon = 'Icon/pecg.ico' , title = BOX_TITLE )
1822+ icon = ico_path [platform ]['pecg' ],
1823+ title = BOX_TITLE )
18101824 break
18111825
18121826 search .join ()
@@ -1887,7 +1901,8 @@ def play_game(self, window, engine_id_name, board):
18871901 # Verify resign
18881902 reply = sg .Popup ('Do you really want to resign?' ,
18891903 button_type = sg .POPUP_BUTTONS_YES_NO ,
1890- title = BOX_TITLE , icon = 'Icon/pecg.ico' )
1904+ title = BOX_TITLE ,
1905+ icon = ico_path [platform ]['pecg' ])
18911906 if reply == 'Yes' :
18921907 is_user_resigns = True
18931908 break
@@ -2345,7 +2360,8 @@ def play_game(self, window, engine_id_name, board):
23452360 self .save_game ()
23462361
23472362 if board .is_game_over (claim_draw = True ):
2348- sg .Popup ('Game is over.' , title = BOX_TITLE , icon = 'Icon/pecg.ico' )
2363+ sg .Popup ('Game is over.' , title = BOX_TITLE ,
2364+ icon = ico_path [platform ]['pecg' ])
23492365
23502366 if is_exit_app :
23512367 window .Close ()
@@ -2502,7 +2518,8 @@ def main_loop(self):
25022518 # Use white layout as default window
25032519 window = sg .Window ('{} {}' .format (APP_NAME , APP_VERSION ),
25042520 layout , default_button_element_size = (12 , 1 ),
2505- auto_size_buttons = False , icon = 'Icon/pecg.ico' )
2521+ auto_size_buttons = False ,
2522+ icon = ico_path [platform ]['pecg' ])
25062523
25072524 # Read user config file, if missing create and new one
25082525 self .check_user_config_file ()
@@ -2568,7 +2585,8 @@ def main_loop(self):
25682585 ]
25692586
25702587 window .Disable ()
2571- w = sg .Window (win_title , layout , icon = 'Icon/pecg.ico' )
2588+ w = sg .Window (win_title , layout ,
2589+ icon = ico_path [platform ]['pecg' ])
25722590 while True :
25732591 e , v = w .Read (timeout = 10 )
25742592 if e is None or e == 'Cancel' :
@@ -2580,7 +2598,8 @@ def main_loop(self):
25802598 sg .Popup ('Please locate your pgn file by pressing '
25812599 'the Browse button followed by Display '
25822600 'Players.' ,
2583- title = win_title , icon = 'Icon/pecg.ico' )
2601+ title = win_title ,
2602+ icon = ico_path [platform ]['pecg' ])
25842603 break
25852604
25862605 t1 = time .perf_counter ()
@@ -2614,7 +2633,8 @@ def main_loop(self):
26142633 logging .info (e )
26152634 sg .Popup ('Please locate your pgn file by '
26162635 'pressing the Browse button followed by Display Players.' ,
2617- title = win_title , icon = 'Icon/pecg.ico' )
2636+ title = win_title ,
2637+ icon = ico_path [platform ]['pecg' ])
26182638 break
26192639 except Exception :
26202640 logging .exception ('Failed to get player.' )
@@ -2678,7 +2698,7 @@ def main_loop(self):
26782698
26792699 window .Disable ()
26802700 w = sg .Window (win_title , layout ,
2681- icon = 'Icon/ pecg.ico' )
2701+ icon = ico_path [ platform ][ ' pecg' ] )
26822702 while True :
26832703 e , v = w .Read (timeout = 10 )
26842704 if e is None :
@@ -2733,7 +2753,7 @@ def main_loop(self):
27332753
27342754 window .Disable ()
27352755 w = sg .Window (win_title , layout ,
2736- icon = 'Icon/ pecg.ico' )
2756+ icon = ico_path [ platform ][ ' pecg' ] )
27372757 while True :
27382758 e , v = w .Read (timeout = 10 )
27392759 if e is None :
@@ -2772,7 +2792,8 @@ def main_loop(self):
27722792 [sg .OK (), sg .Cancel ()]
27732793 ]
27742794 window .Disable ()
2775- w = sg .Window (win_title , layout , icon = 'Icon/pecg.ico' )
2795+ w = sg .Window (win_title , layout ,
2796+ icon = ico_path [platform ]['pecg' ])
27762797 while True :
27772798 e , v = w .Read (timeout = 10 )
27782799 if e is None :
@@ -2806,7 +2827,7 @@ def main_loop(self):
28062827 window .Disable ()
28072828 install_win = sg .Window (title = button_title ,
28082829 layout = install_layout ,
2809- icon = 'Icon/ pecg.ico' )
2830+ icon = ico_path [ platform ][ ' pecg' ] )
28102831
28112832 while True :
28122833 e , v = install_win .Read (timeout = 100 )
@@ -2889,15 +2910,15 @@ def main_loop(self):
28892910 'Engine->Manage->Edit' .format (
28902911 new_engine_id_name ),
28912912 title = button_title ,
2892- icon = 'Icon/ pecg.ico' )
2913+ icon = ico_path [ platform ][ ' pecg' ] )
28932914 continue
28942915 break
28952916 else :
28962917 sg .Popup ('Please input engine id '
28972918 'name, or press Get Id Name '
28982919 'button.' ,
28992920 title = button_title ,
2900- icon = 'Icon/ pecg.ico' )
2921+ icon = ico_path [ platform ][ ' pecg' ] )
29012922 except Exception :
29022923 logging .exception ('Failed to get engine '
29032924 'path and file' )
@@ -2926,7 +2947,7 @@ def main_loop(self):
29262947 sg .Popup ('Failed to add {} in config '
29272948 'file!' .format (new_engine_id_name ),
29282949 title = button_title ,
2929- icon = 'Icon/ pecg.ico' )
2950+ icon = ico_path [ platform ][ ' pecg' ] )
29302951
29312952 self .engine_id_name_list = \
29322953 self .get_engine_id_name_list ()
@@ -2953,7 +2974,7 @@ def main_loop(self):
29532974
29542975 window .Disable ()
29552976 edit_win = sg .Window (button_title , layout = edit_layout ,
2956- icon = 'Icon/ pecg.ico' )
2977+ icon = ico_path [ platform ][ ' pecg' ] )
29572978 is_cancel_edit_win = False
29582979 while True :
29592980 e , v = edit_win .Read (timeout = 100 )
@@ -2969,7 +2990,7 @@ def main_loop(self):
29692990 except Exception :
29702991 sg .Popup ('Please select an engine to modify.' ,
29712992 title = '/Edit/Modify' ,
2972- icon = 'Icon/ pecg.ico' )
2993+ icon = ico_path [ platform ][ ' pecg' ] )
29732994 continue
29742995
29752996 # Read engine config file
@@ -3103,7 +3124,7 @@ def main_loop(self):
31033124 edit_win .Disable ()
31043125 modify_win = sg .Window (button_title ,
31053126 layout = modify_layout ,
3106- icon = 'Icon/ pecg.ico' )
3127+ icon = ico_path [ platform ][ ' pecg' ] )
31073128 is_cancel_modify_win = False
31083129 while True :
31093130 e1 , v1 = modify_win .Read (timeout = 100 )
@@ -3145,7 +3166,7 @@ def main_loop(self):
31453166 ]
31463167 window .Disable ()
31473168 delete_win = sg .Window (button_title , layout = delete_layout ,
3148- icon = 'Icon/ pecg.ico' )
3169+ icon = ico_path [ platform ][ ' pecg' ] )
31493170 is_cancel = False
31503171 while True :
31513172 e , v = delete_win .Read (timeout = 100 )
@@ -3157,7 +3178,8 @@ def main_loop(self):
31573178 engine_id_name = v ['engine_id_name_k' ][0 ]
31583179 except Exception :
31593180 sg .Popup ('Please select an engine to delete.' ,
3160- title = button_title , icon = 'Icon/pecg.ico' )
3181+ title = button_title ,
3182+ icon = ico_path [platform ]['pecg' ])
31613183 continue
31623184 with open (self .engine_config_file , 'r' ) as json_file :
31633185 data = json .load (json_file )
@@ -3203,7 +3225,7 @@ def main_loop(self):
32033225
32043226 # Create new window and disable the main window
32053227 w = sg .Window (BOX_TITLE + '/Select opponent' , layout ,
3206- icon = 'Icon/ enemy.ico' )
3228+ icon = ico_path [ platform ][ ' enemy' ] )
32073229 window .Disable ()
32083230
32093231 while True :
@@ -3263,7 +3285,8 @@ def main_loop(self):
32633285 ]
32643286
32653287 # Create new window and disable the main window
3266- w = sg .Window (BOX_TITLE + '/Select Adviser' , layout , icon = 'Icon/adviser.ico' )
3288+ w = sg .Window (BOX_TITLE + '/Select Adviser' , layout ,
3289+ icon = ico_path [platform ]['adviser' ])
32673290 window .Disable ()
32683291
32693292 while True :
@@ -3325,7 +3348,8 @@ def main_loop(self):
33253348 [sg .OK (), sg .Cancel ()],
33263349 ]
33273350
3328- w = sg .Window (BOX_TITLE + '/Set Book' , layout , icon = 'Icon/pecg.ico' )
3351+ w = sg .Window (BOX_TITLE + '/Set Book' , layout ,
3352+ icon = ico_path [platform ]['pecg' ])
33293353 window .Disable ()
33303354
33313355 while True :
@@ -3370,7 +3394,8 @@ def main_loop(self):
33703394 [sg .OK (), sg .Cancel ()],
33713395 ]
33723396
3373- w = sg .Window (win_title , layout , icon = 'Icon/pecg.ico' )
3397+ w = sg .Window (win_title , layout ,
3398+ icon = ico_path [platform ]['pecg' ])
33743399 window .Disable ()
33753400
33763401 while True :
@@ -3448,7 +3473,7 @@ def main_loop(self):
34483473 if engine_id_name is None :
34493474 logging .warning ('Install engine first!' )
34503475 sg .Popup ('Install engine first! in Engine/Manage/Install' ,
3451- icon = 'Icon/ pecg.ico' , title = 'Mode' )
3476+ icon = ico_path [ platform ][ ' pecg' ] , title = 'Mode' )
34523477 continue
34533478
34543479 # Change menu from Neutral to Play
0 commit comments