|
53 | 53 |
|
54 | 54 |
|
55 | 55 | APP_NAME = 'Python Easy Chess GUI' |
56 | | -APP_VERSION = 'v0.72' |
| 56 | +APP_VERSION = 'v0.73' |
57 | 57 | BOX_TITLE = '{} {}'.format(APP_NAME, APP_VERSION) |
58 | 58 |
|
59 | 59 |
|
@@ -247,14 +247,14 @@ def get_book_move(self): |
247 | 247 | def get_all_moves(self): |
248 | 248 | is_found = False |
249 | 249 | if os.path.isfile(self.book_file): |
250 | | - moves = '{:5s} {:<}\n'.format('move', 'weight') |
| 250 | + moves = '{:5s} {:<}\n'.format('move', 'score') |
251 | 251 | with chess.polyglot.open_reader(self.book_file) as reader: |
252 | 252 | for entry in reader.find_all(self.board): |
253 | 253 | is_found = True |
254 | 254 | san_move = self.board.san(entry.move) |
255 | 255 | moves += '{:5s} {:<}\n'.format(san_move, entry.weight) |
256 | 256 | else: |
257 | | - moves = '{:5s} {:<}\n'.format('move', 'weight') |
| 257 | + moves = '{:5s} {:<}\n'.format('move', 'score') |
258 | 258 |
|
259 | 259 | return moves, is_found |
260 | 260 |
|
@@ -951,8 +951,7 @@ def play_game(self, engine_id_name, board): |
951 | 951 | default = True if self.is_random_book else False)], |
952 | 952 | [sg.OK(), sg.Cancel()], |
953 | 953 | ] |
954 | | - |
955 | | - self.window.Hide() |
| 954 | + |
956 | 955 | w = sg.Window(BOX_TITLE, layout) |
957 | 956 |
|
958 | 957 | while True: |
@@ -981,7 +980,9 @@ def play_game(self, engine_id_name, board): |
981 | 980 | break |
982 | 981 |
|
983 | 982 | w.Close() |
984 | | - self.window.UnHide() |
| 983 | + while True: |
| 984 | + button, value = self.window.Read(timeout=50) |
| 985 | + break |
985 | 986 | continue |
986 | 987 |
|
987 | 988 | if button == 'New::new_game_k': |
@@ -1029,7 +1030,6 @@ def play_game(self, engine_id_name, board): |
1029 | 1030 | [sg.OK(), sg.Cancel()] |
1030 | 1031 | ] |
1031 | 1032 |
|
1032 | | - self.window.Hide() |
1033 | 1033 | w = sg.Window('Engine Settings', layout) |
1034 | 1034 |
|
1035 | 1035 | while True: |
@@ -1070,7 +1070,9 @@ def play_game(self, engine_id_name, board): |
1070 | 1070 | break |
1071 | 1071 |
|
1072 | 1072 | w.Close() |
1073 | | - self.window.UnHide() |
| 1073 | + while True: |
| 1074 | + button, value = self.window.Read(timeout=50) |
| 1075 | + break |
1074 | 1076 | self.update_labels_and_game_tags(human='Human', |
1075 | 1077 | engine_id=self.get_engine_id_name()) |
1076 | 1078 | continue |
@@ -1180,7 +1182,6 @@ def play_game(self, engine_id_name, board): |
1180 | 1182 | [sg.OK(), sg.Cancel()] |
1181 | 1183 | ] |
1182 | 1184 |
|
1183 | | - self.window.Hide() |
1184 | 1185 | w = sg.Window('Engine Settings', layout) |
1185 | 1186 |
|
1186 | 1187 | while True: |
@@ -1221,7 +1222,9 @@ def play_game(self, engine_id_name, board): |
1221 | 1222 | break |
1222 | 1223 |
|
1223 | 1224 | w.Close() |
1224 | | - self.window.UnHide() |
| 1225 | + while True: |
| 1226 | + button, value = self.window.Read(timeout=50) |
| 1227 | + break |
1225 | 1228 | self.update_labels_and_game_tags(human='Human', |
1226 | 1229 | engine_id=self.get_engine_id_name()) |
1227 | 1230 | continue |
@@ -1250,8 +1253,7 @@ def play_game(self, engine_id_name, board): |
1250 | 1253 | default = True if self.is_random_book else False)], |
1251 | 1254 | [sg.OK(), sg.Cancel()], |
1252 | 1255 | ] |
1253 | | - |
1254 | | - self.window.Hide() |
| 1256 | + |
1255 | 1257 | w = sg.Window(BOX_TITLE, layout) |
1256 | 1258 |
|
1257 | 1259 | while True: |
@@ -1280,7 +1282,9 @@ def play_game(self, engine_id_name, board): |
1280 | 1282 | break |
1281 | 1283 |
|
1282 | 1284 | w.Close() |
1283 | | - self.window.UnHide() |
| 1285 | + while True: |
| 1286 | + button, value = self.window.Read(timeout=50) |
| 1287 | + break |
1284 | 1288 | continue |
1285 | 1289 |
|
1286 | 1290 | if button is None: |
@@ -1919,9 +1923,7 @@ def main_loop(self): |
1919 | 1923 | size=(8, 1), key='hash_k')], |
1920 | 1924 | [sg.OK(), sg.Cancel()] |
1921 | 1925 | ] |
1922 | | - |
1923 | | - # Hide the main window temporarily and build a new one. |
1924 | | - self.window.Hide() |
| 1926 | + |
1925 | 1927 | w = sg.Window('Engine Settings', layout) |
1926 | 1928 |
|
1927 | 1929 | while True: |
@@ -1965,7 +1967,9 @@ def main_loop(self): |
1965 | 1967 |
|
1966 | 1968 | # Close the new window and restore/unhide the main window |
1967 | 1969 | w.Close() |
1968 | | - self.window.UnHide() |
| 1970 | + while True: |
| 1971 | + button, value = self.window.Read(timeout=50) |
| 1972 | + break |
1969 | 1973 |
|
1970 | 1974 | # Update the player box in main window |
1971 | 1975 | self.update_labels_and_game_tags(human='Human', |
@@ -2005,7 +2009,6 @@ def main_loop(self): |
2005 | 2009 | [sg.OK(), sg.Cancel()], |
2006 | 2010 | ] |
2007 | 2011 |
|
2008 | | - self.window.Hide() |
2009 | 2012 | w = sg.Window(BOX_TITLE, layout) |
2010 | 2013 |
|
2011 | 2014 | while True: |
@@ -2034,7 +2037,12 @@ def main_loop(self): |
2034 | 2037 | break |
2035 | 2038 |
|
2036 | 2039 | w.Close() |
2037 | | - self.window.UnHide() |
| 2040 | + |
| 2041 | + # Disable any button presses by the user in the main window |
| 2042 | + # while the book setting window is active. |
| 2043 | + while True: |
| 2044 | + button, value = self.window.Read(timeout=50) |
| 2045 | + break |
2038 | 2046 | continue |
2039 | 2047 |
|
2040 | 2048 | if button == 'Flip': |
|
0 commit comments