Adds entry method

This commit is contained in:
LSaldyt
2017-10-22 13:05:28 -07:00
parent 354470bcd7
commit dcf5b252c3
6 changed files with 49 additions and 22 deletions

View File

@ -2,6 +2,7 @@ import tkinter as tk
import tkinter.ttk as ttk
from .gridframe import GridFrame
from .entry import Entry
class Control(GridFrame):
def __init__(self, parent, *args, **kwargs):
@ -9,13 +10,20 @@ class Control(GridFrame):
self.paused = True
self.steps = 0
self.go = False
self.playbutton = tk.Button(self, bd=0, text='Play', command=lambda : self.toggle(), background='black', foreground='white', activebackground='black', activeforeground='blue')
self.add(self.playbutton, 0, 0)
self.stepbutton= tk.Button(self, bd=0, text='Step', command=lambda : self.step(), background='black', foreground='white', activebackground='black', activeforeground='blue')
self.stepbutton = tk.Button(self, bd=0, text='Step', command=lambda : self.step(), background='black', foreground='white', activebackground='black', activeforeground='blue')
self.add(self.stepbutton, 1, 0)
self.entry = Entry(self)
self.add(self.entry, 0, 1, xspan=2)
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 toggle(self):
self.paused = not self.paused
self.playbutton['text'] = 'Pause' if not self.paused else 'Play'
@ -29,3 +37,9 @@ class Control(GridFrame):
return True
else:
return False
def set_go(self):
self.go = True
def get_vars(self):
return self.entry.a.get(), self.entry.b.get(), self.entry.c.get()

28
copycat/gui/entry.py Normal file
View File

@ -0,0 +1,28 @@
import tkinter as tk
import tkinter.ttk as ttk
from .gridframe import GridFrame
style = dict(background='black', foreground='white')
class Entry(GridFrame):
def __init__(self, parent, *args, **kwargs):
GridFrame.__init__(self, parent, *args, **kwargs)
self.aLabel = tk.Label(self, text='Initial:', **style)
self.a = tk.Entry(self, **style)
self.add(self.aLabel, 0, 0)
self.add(self.a, 0, 1)
self.bLabel = tk.Label(self, text='Final:', **style)
self.b = tk.Entry(self, **style)
self.add(self.bLabel, 1, 0)
self.add(self.b, 1, 1)
self.cLabel = tk.Label(self, text='Next:', **style)
self.c = tk.Entry(self, **style)
self.add(self.cLabel, 2, 0)
self.add(self.c, 2, 1)