Converts to ttk
This commit is contained in:
@ -12,16 +12,16 @@ class Control(GridFrame):
|
||||
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.playbutton = ttk.Button(self, text='Play', command=lambda : self.toggle())
|
||||
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 = ttk.Button(self, text='Step', command=lambda : self.step())
|
||||
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.gobutton = ttk.Button(self, text='Go', command=lambda : self.set_go())
|
||||
self.add(self.gobutton, 0, 2, xspan=2)
|
||||
|
||||
def play(self):
|
||||
|
||||
@ -4,25 +4,23 @@ 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.aLabel = ttk.Label(self, text='Initial:')
|
||||
self.a = ttk.Entry(self)
|
||||
|
||||
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.bLabel = ttk.Label(self, text='Final:')
|
||||
self.b = ttk.Entry(self)
|
||||
|
||||
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.cLabel = ttk.Label(self, text='Next:')
|
||||
self.c = ttk.Entry(self)
|
||||
|
||||
self.add(self.cLabel, 2, 0)
|
||||
self.add(self.c, 2, 1)
|
||||
|
||||
@ -3,7 +3,7 @@ import tkinter.ttk as ttk
|
||||
|
||||
class GridFrame(tk.Frame):
|
||||
def __init__(self, parent, *args, **kwargs):
|
||||
tk.Frame.__init__(self, parent, *args, **kwargs, bd=0)
|
||||
ttk.Frame.__init__(self, parent, *args, **kwargs)
|
||||
|
||||
def add(self, element, x, y, xspan=1, yspan=1):
|
||||
element.grid(column=x, row=y, columnspan=xspan, rowspan=yspan, sticky=tk.N+tk.E+tk.S+tk.W)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
|
||||
import time
|
||||
|
||||
@ -8,7 +9,7 @@ class List(GridFrame):
|
||||
|
||||
def __init__(self, parent, columns, updateInterval=.1, **style):
|
||||
GridFrame.__init__(self, parent)
|
||||
self.text = tk.Label(self, **style, anchor='w', justify=tk.LEFT, width=30)
|
||||
self.text = ttk.Label(self, anchor='w', justify=tk.LEFT, width=30)
|
||||
self.add(self.text, 0, 0)
|
||||
|
||||
self.columns = columns
|
||||
|
||||
@ -49,18 +49,3 @@ class Status(object):
|
||||
def update_plots(self, i):
|
||||
self.subplot.clear()
|
||||
self.modifier(self)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = tk.Tk()
|
||||
status = Status()
|
||||
sframe = StatusFrame(app, status, 'x**2')
|
||||
sframe.pack()
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
app.update()
|
||||
app.update_idletasks()
|
||||
time.sleep(.01)
|
||||
i += 1
|
||||
status.x += [i]
|
||||
status.y += [i**2]
|
||||
|
||||
Reference in New Issue
Block a user