Merge pull request #2821 from PySimpleGUI/Dev-latest
Better window management. Show popup when exiting so doesn't appear …
This commit is contained in:
commit
0a2bc0c235
|
@ -105,7 +105,7 @@ class GameOfLife:
|
||||||
background_color='lightblue')
|
background_color='lightblue')
|
||||||
layout = [
|
layout = [
|
||||||
[sg.Text('Game of Life', font='ANY 15'),
|
[sg.Text('Game of Life', font='ANY 15'),
|
||||||
sg.Text('', key='-OUTPUT-', size=(30, 1), font='ANY 15')],
|
sg.Text('Click below to place cells', key='-OUTPUT-', size=(30, 1), font='ANY 15')],
|
||||||
[self.graph],
|
[self.graph],
|
||||||
[sg.Button('Go!', key='-DONE-'),
|
[sg.Button('Go!', key='-DONE-'),
|
||||||
sg.Text(' Delay (ms)'),
|
sg.Text(' Delay (ms)'),
|
||||||
|
@ -142,6 +142,8 @@ class GameOfLife:
|
||||||
line_color='black', fill_color='yellow')
|
line_color='black', fill_color='yellow')
|
||||||
event, values = self.window.read(timeout=self.delay)
|
event, values = self.window.read(timeout=self.delay)
|
||||||
if event in (None, '-DONE-'):
|
if event in (None, '-DONE-'):
|
||||||
|
sg.popup('Click OK to exit the program...')
|
||||||
|
self.window.close()
|
||||||
exit()
|
exit()
|
||||||
self.delay = values['-SLIDER-']
|
self.delay = values['-SLIDER-']
|
||||||
self.T = int(values['-SLIDER2-'])
|
self.T = int(values['-SLIDER2-'])
|
||||||
|
@ -179,10 +181,14 @@ class GameOfLife:
|
||||||
line_color='black', fill_color='yellow')
|
line_color='black', fill_color='yellow')
|
||||||
ids[box_x][box_y] = id_val
|
ids[box_x][box_y] = id_val
|
||||||
self.old_grid[box_x][box_y] = 1
|
self.old_grid[box_x][box_y] = 1
|
||||||
|
if event is None:
|
||||||
|
self.window.close()
|
||||||
|
else:
|
||||||
self.window['-DONE-'].update(text='Exit')
|
self.window['-DONE-'].update(text='Exit')
|
||||||
|
|
||||||
|
|
||||||
if (__name__ == "__main__"):
|
if (__name__ == "__main__"):
|
||||||
game = GameOfLife(N=35, T=200)
|
game = GameOfLife(N=35, T=200)
|
||||||
game.play()
|
game.play()
|
||||||
|
sg.popup('Completed running.', 'Click OK to exit the program')
|
||||||
game.window.close()
|
game.window.close()
|
||||||
|
|
Loading…
Reference in New Issue