Merge pull request #1384 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2019-05-08 14:54:30 -04:00 committed by GitHub
commit 823dac6cc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -23,7 +23,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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
@ -102,13 +103,15 @@ class GameOfLife:
[sg.Text('Game of Life ', font='ANY 15'), sg.Text('', key='_OUTPUT_', size=(30,1), font='ANY 15')],
[self.graph],
[sg.Button('Go!', key='_DONE_'),
sg.Text(' Delay (ms)') , sg.Slider([0,400], orientation='h', key='_SLIDER_', size=(15,15)),
sg.Text(' Num Generations'), sg.Slider([0, 3000],default_value=400, orientation='h',size=(15,15), key='_SLIDER2_')]
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),enable_events=True, key='_SLIDER2_'), sg.T('', size=(3,1), key='_S2_OUT_')]
]
self.window = sg.Window('Window Title', ).Layout(layout).Finalize()
event, values = self.window.Read(timeout=0)
self.delay = values['_SLIDER_']
self.window.Element('_S1_OUT_').Update(values['_SLIDER_'])
self.window.Element('_S2_OUT_').Update(values['_SLIDER2_'])
def draw_board(self):
@ -125,8 +128,11 @@ class GameOfLife:
exit()
self.delay = values['_SLIDER_']
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))
def manual_board_setup(self):
ids = []
for i in range(self.N):
@ -137,6 +143,8 @@ class GameOfLife:
event, values = self.window.Read()
if event is None or event == '_DONE_':
break
self.window.Element('_S1_OUT_').Update(values['_SLIDER_'])
self.window.Element('_S2_OUT_').Update(values['_SLIDER2_'])
mouse = values['_GRAPH_']
if event == '_GRAPH_':
@ -159,3 +167,4 @@ class GameOfLife:
if (__name__ == "__main__"):
game = GameOfLife(N=35, T=200)
game.play()
game.window.Close()

View File

@ -1816,7 +1816,7 @@ class Graph(Element):
print('Call Window.Finalize() prior to this operation')
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_fill(fill_color)
self.SvgGroup.append([rpoint,])