Skip to content

Commit fb2715d

Browse files
committed
Update python_easy_chess_gui.py
* Modify code on Flip. Locate the new window to the old window location after a flip.
1 parent 830b35f commit fb2715d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

python_easy_chess_gui.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
APP_NAME = 'Python Easy Chess GUI'
56-
APP_VERSION = 'v0.66'
56+
APP_VERSION = 'v0.67'
5757
BOX_TITLE = '{} {}'.format(APP_NAME, APP_VERSION)
5858

5959

@@ -1958,24 +1958,26 @@ def main_loop(self):
19581958
continue
19591959

19601960
if button == 'Flip':
1961-
# Clear Text and Multiline elements
19621961
self.window.FindElement('_gamestatus_').Update('Mode Neutral')
19631962
self.clear_elements()
19641963

1965-
window1 = sg.Window('{} {}'.format(APP_NAME, APP_VERSION),
1964+
# Get the current location of window before closing it.
1965+
# We will use this loc when we create a new window.
1966+
loc = self.window.CurrentLocation()
1967+
self.window.Close()
1968+
1969+
self.window = sg.Window('{} {}'.format(APP_NAME, APP_VERSION),
19661970
self.black_layout if self.is_user_white else self.white_layout,
19671971
default_button_element_size=(12, 1),
1968-
auto_size_buttons=False,
1969-
icon='')
1972+
auto_size_buttons=False, location=(loc[0], loc[1]),
1973+
keep_on_top = True, icon='')
19701974
self.is_user_white = not self.is_user_white
19711975

19721976
self.update_labels_and_game_tags(human='Human',
19731977
engine_id=engine_id_name)
1974-
1975-
self.window.Close()
19761978
self.psg_board = copy.deepcopy(initial_board)
19771979
board = chess.Board()
1978-
self.window = window1
1980+
self.window.Refresh()
19791981
continue
19801982

19811983
# Menu->Help->Help

0 commit comments

Comments
 (0)