commit
823dac6cc8
|
@ -23,7 +23,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg # Take your pick! Tkinter
|
||||||
|
# import PySimpleGUIWeb as sg # Or the Web! (Remi!)
|
||||||
|
|
||||||
BOX_SIZE = 15
|
BOX_SIZE = 15
|
||||||
|
|
||||||
|
@ -102,13 +103,15 @@ class GameOfLife:
|
||||||
[sg.Text('Game of Life ', font='ANY 15'), sg.Text('', key='_OUTPUT_', size=(30,1), font='ANY 15')],
|
[sg.Text('Game of Life ', font='ANY 15'), sg.Text('', 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.Slider([0,400], orientation='h', key='_SLIDER_', size=(15,15)),
|
sg.Text(' Delay (ms)') , sg.Slider([0,400], orientation='h', key='_SLIDER_', enable_events=True, size=(15,15)), sg.T('', size=(3,1), key='_S1_OUT_'),
|
||||||
sg.Text(' Num Generations'), sg.Slider([0, 3000],default_value=400, orientation='h',size=(15,15), key='_SLIDER2_')]
|
sg.Text(' Num Generations'), sg.Slider([0, 3000],default_value=400, orientation='h',size=(15,15),enable_events=True, key='_SLIDER2_'), sg.T('', size=(3,1), key='_S2_OUT_')]
|
||||||
]
|
]
|
||||||
|
|
||||||
self.window = sg.Window('Window Title', ).Layout(layout).Finalize()
|
self.window = sg.Window('Window Title', ).Layout(layout).Finalize()
|
||||||
event, values = self.window.Read(timeout=0)
|
event, values = self.window.Read(timeout=0)
|
||||||
self.delay = values['_SLIDER_']
|
self.delay = values['_SLIDER_']
|
||||||
|
self.window.Element('_S1_OUT_').Update(values['_SLIDER_'])
|
||||||
|
self.window.Element('_S2_OUT_').Update(values['_SLIDER2_'])
|
||||||
|
|
||||||
|
|
||||||
def draw_board(self):
|
def draw_board(self):
|
||||||
|
@ -125,8 +128,11 @@ class GameOfLife:
|
||||||
exit()
|
exit()
|
||||||
self.delay = values['_SLIDER_']
|
self.delay = values['_SLIDER_']
|
||||||
self.T = int(values['_SLIDER2_'])
|
self.T = int(values['_SLIDER2_'])
|
||||||
|
self.window.Element('_S1_OUT_').Update(values['_SLIDER_'])
|
||||||
|
self.window.Element('_S2_OUT_').Update(values['_SLIDER2_'])
|
||||||
self.window.Element('_OUTPUT_').Update('Generation {}'.format(self.t))
|
self.window.Element('_OUTPUT_').Update('Generation {}'.format(self.t))
|
||||||
|
|
||||||
|
|
||||||
def manual_board_setup(self):
|
def manual_board_setup(self):
|
||||||
ids = []
|
ids = []
|
||||||
for i in range(self.N):
|
for i in range(self.N):
|
||||||
|
@ -137,6 +143,8 @@ class GameOfLife:
|
||||||
event, values = self.window.Read()
|
event, values = self.window.Read()
|
||||||
if event is None or event == '_DONE_':
|
if event is None or event == '_DONE_':
|
||||||
break
|
break
|
||||||
|
self.window.Element('_S1_OUT_').Update(values['_SLIDER_'])
|
||||||
|
self.window.Element('_S2_OUT_').Update(values['_SLIDER2_'])
|
||||||
mouse = values['_GRAPH_']
|
mouse = values['_GRAPH_']
|
||||||
|
|
||||||
if event == '_GRAPH_':
|
if event == '_GRAPH_':
|
||||||
|
@ -159,3 +167,4 @@ class GameOfLife:
|
||||||
if (__name__ == "__main__"):
|
if (__name__ == "__main__"):
|
||||||
game = GameOfLife(N=35, T=200)
|
game = GameOfLife(N=35, T=200)
|
||||||
game.play()
|
game.play()
|
||||||
|
game.window.Close()
|
|
@ -1816,7 +1816,7 @@ class Graph(Element):
|
||||||
print('Call Window.Finalize() prior to this operation')
|
print('Call Window.Finalize() prior to this operation')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
rpoint = remi.gui.SvgRectangle(converted_top_left[0], converted_top_left[1], bottom_right[0]-top_left[0], top_left[1] - bottom_right[1])
|
rpoint = remi.gui.SvgRectangle(converted_top_left[0], converted_top_left[1], converted_bottom_right[0]-converted_top_left[0], converted_top_left[1] - converted_bottom_right[1])
|
||||||
rpoint.set_stroke(width=1, color=line_color)
|
rpoint.set_stroke(width=1, color=line_color)
|
||||||
rpoint.set_fill(fill_color)
|
rpoint.set_fill(fill_color)
|
||||||
self.SvgGroup.append([rpoint,])
|
self.SvgGroup.append([rpoint,])
|
||||||
|
|
Loading…
Reference in New Issue