From cc35cb9de2462dade07fade40471e46de554fff1 Mon Sep 17 00:00:00 2001 From: LSaldyt Date: Wed, 25 Oct 2017 10:54:54 -0700 Subject: [PATCH] Adds play on go --- copycat/gui/control.py | 15 +++++++++++++-- copycat/gui/gui.py | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/copycat/gui/control.py b/copycat/gui/control.py index 069c69d..1c1e1a1 100644 --- a/copycat/gui/control.py +++ b/copycat/gui/control.py @@ -24,9 +24,19 @@ class Control(GridFrame): self.gobutton = tk.Button(self, bd=0, text='Go', command=lambda : self.set_go(), background='black', foreground='white', activebackground='black', activeforeground='blue') self.add(self.gobutton, 0, 2, xspan=2) + def play(self): + self.paused = False + self.playbutton['text'] = 'Pause' + + def pause(self): + self.paused = True + self.playbutton['text'] = 'Play' + def toggle(self): - self.paused = not self.paused - self.playbutton['text'] = 'Pause' if not self.paused else 'Play' + if self.paused: + self.play() + else: + self.pause() def step(self): self.steps += 1 @@ -40,6 +50,7 @@ class Control(GridFrame): def set_go(self): self.go = True + self.play() def get_vars(self): return self.entry.a.get(), self.entry.b.get(), self.entry.c.get() diff --git a/copycat/gui/gui.py b/copycat/gui/gui.py index 47dd9dc..f8f8145 100755 --- a/copycat/gui/gui.py +++ b/copycat/gui/gui.py @@ -33,8 +33,9 @@ class MainApplication(GridFrame): self.parent = parent self.primary = Primary(self, *args, **kwargs) - self.add(self.primary, 0, 0) + self.add(self.primary, 0, 0, ) self.create_widgets() + GridFrame.configure(self) self.iterations = 0