This commit is contained in:
LSaldyt
2017-10-26 12:52:58 -07:00
parent 2187511706
commit 80b6e49581
5 changed files with 22 additions and 33 deletions

View File

@ -24,3 +24,4 @@ class Entry(GridFrame):
self.add(self.cLabel, 2, 0)
self.add(self.c, 2, 1)
GridFrame.configure(self)

View File

@ -7,5 +7,5 @@ class GridFrame(tk.Frame):
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)
self.rowconfigure(x, weight=1)
self.columnconfigure(y, weight=1)
tk.Grid.rowconfigure(self, x, weight=1)
tk.Grid.columnconfigure(self, y, weight=1)

View File

@ -18,15 +18,6 @@ from .style import configure_style
from .plot import plot_imbedded
font1Size = 32
font2Size = 12
font1 = ('Helvetica', str(font1Size))
font2 = ('Helvetica', str(font2Size))
style = dict(background='black',
foreground='white',
font=font2)
plt.style.use('dark_background')
class MainApplication(GridFrame):
@ -36,33 +27,29 @@ class MainApplication(GridFrame):
self.parent = parent
self.primary = Primary(self, *args, **kwargs)
self.add(self.primary, 0, 0, )
self.add(self.primary, 0, 0, xspan=2)
self.create_widgets()
GridFrame.configure(self)
self.messages = []
#self.messages = []
def log(self, message):
self.messages.append(message)
#def log(self, message):
# self.messages.append(message)
def create_widgets(self):
self.slipList = List(self, 10, **style)
self.slipList = List(self, 10)
self.add(self.slipList, 0, 1)
self.codeletList = List(self, 10, **style)
self.codeletList = List(self, 10)
self.add(self.codeletList, 1, 1)
self.objectList = List(self, 10, **style)
self.objectList = List(self, 10)
self.add(self.objectList, 2, 1)
self.logBox = List(self, 10, **style)
self.add(self.logBox, 1, 0)
#self.logBox = List(self, 10)
#self.add(self.logBox, 1, 0)
self.graph2 = Plot(self, 'Answer Distribution')
#self.graph2 = Status()
#sframe2 = StatusFrame(self, self.graph2, 'graph 2')
#self.add(sframe2, 2, 0)
self.add(self.graph2, 2, 0)
def update(self, copycat):
@ -72,11 +59,11 @@ class MainApplication(GridFrame):
codelets = copycat.coderack.codelets
objects = copycat.workspace.objects
self.slipList.update(slipnodes, key=lambda s:s.activation, reverse=True,
self.slipList.update(slipnodes, key=lambda s:s.activation,
formatter=lambda s : '{}: {}'.format(s.name, round(s.activation, 2)))
self.codeletList.update(codelets, key=lambda c:c.urgency, reverse=True, formatter= lambda s : '{}: {}'.format(s.name, round(s.urgency, 2)))
self.objectList.update(objects)
self.logBox.update(list(reversed(self.messages))[:10])
self.codeletList.update(codelets, key=lambda c:c.urgency, formatter= lambda s : '{}: {}'.format(s.name, round(s.urgency, 2)))
self.objectList.update(objects, formatter=lambda s : '{}'.format(str(s.descriptions)))
#self.logBox.update(list(reversed(self.messages))[:10])
def reset_with_strings(self, initial, modified, target):
self.primary.reset_with_strings(initial, modified, target)

View File

@ -7,7 +7,7 @@ from .gridframe import GridFrame
class List(GridFrame):
def __init__(self, parent, columns, updateInterval=.1, **style):
def __init__(self, parent, columns, updateInterval=.1):
GridFrame.__init__(self, parent)
self.text = ttk.Label(self, anchor='w', justify=tk.LEFT, width=30)
self.add(self.text, 0, 0)

View File

@ -41,8 +41,8 @@ def create_main_canvas(root, initial, final, new, guess):
add_sequences([new, guess], x, y)
canvas['height'] = str(int(canvas['height']) + padding)
canvas['width'] = str(int(canvas['width']) + padding)
#canvas['height'] = str(int(canvas['height']) + padding)
#canvas['width'] = str(int(canvas['width']) + padding)
return canvas
@ -59,11 +59,12 @@ class Primary(GridFrame):
self.add(self.canvas, 0, 0, xspan=2)
self.control = Control(self)
self.add(self.control, 0, 2)
GridFrame.configure(self)
def update(self, copycat):
answer = '' if copycat.workspace.rule is None else copycat.workspace.rule.buildTranslatedRule()
self.canvas = create_main_canvas(self, self.initial, self.modified, self.target, answer)
self.add(self.canvas, 0, 0, xspan=2)
#self.canvas = create_main_canvas(self, self.initial, self.modified, self.target, answer)
#self.add(self.canvas, 0, 0, xspan=2)
def reset_with_strings(self, initial, modified, target):
self.initial = initial