Adds logging and basic object view
This commit is contained in:
@ -7,6 +7,8 @@ import tkinter.ttk as ttk
|
||||
from tkinter import scrolledtext
|
||||
from tkinter import filedialog
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from .status import Status, StatusFrame
|
||||
from .gridframe import GridFrame
|
||||
from .primary import Primary
|
||||
@ -14,7 +16,7 @@ from .primary import Primary
|
||||
from .plot import plot_imbedded
|
||||
|
||||
font1Size = 32
|
||||
font2Size = 16
|
||||
font2Size = 12
|
||||
font1 = ('Helvetica', str(font1Size))
|
||||
font2 = ('Helvetica', str(font2Size))
|
||||
|
||||
@ -22,11 +24,12 @@ style = dict(background='black',
|
||||
foreground='white',
|
||||
font=font2)
|
||||
|
||||
plt.style.use('dark_background')
|
||||
|
||||
class MainApplication(GridFrame):
|
||||
|
||||
def __init__(self, parent, *args, **kwargs):
|
||||
GridFrame.__init__(self, parent, *args, **kwargs)
|
||||
self.widgets = dict()
|
||||
|
||||
self.parent = parent
|
||||
self.primary = Primary(self, *args, **kwargs)
|
||||
@ -37,20 +40,20 @@ class MainApplication(GridFrame):
|
||||
|
||||
def create_widgets(self):
|
||||
|
||||
slipList = tk.Listbox(self, **style, bd=0)
|
||||
self.add(slipList, 0, 1)
|
||||
self.widgets['sliplist'] = slipList
|
||||
self.slipList = tk.Listbox(self, **style, bd=0)
|
||||
self.add(self.slipList, 0, 1)
|
||||
|
||||
codeletList = tk.Listbox(self, **style, bd=0)
|
||||
self.add(codeletList, 1, 1)
|
||||
self.widgets['codeletlist'] = codeletList
|
||||
self.codeletList = tk.Listbox(self, **style, bd=0)
|
||||
self.add(self.codeletList, 1, 1)
|
||||
|
||||
l = ttk.Label(self, text='', **style, padding=30)
|
||||
self.add(l, 2, 1)
|
||||
self.objectList = tk.Listbox(self, **style, bd=0)
|
||||
self.add(self.objectList, 2, 1)
|
||||
|
||||
self.graph1 = Status()
|
||||
sframe1 = StatusFrame(self, self.graph1, 'graph 1')
|
||||
self.add(sframe1, 1, 0)
|
||||
#l = ttk.Label(self, text='', **style, padding=30)
|
||||
#self.add(l, 2, 1)
|
||||
|
||||
self.log = tk.Label(self, text='[Logging]', **style)
|
||||
self.add(self.log, 1, 0)
|
||||
self.graph2 = Status()
|
||||
sframe2 = StatusFrame(self, self.graph2, 'graph 2')
|
||||
self.add(sframe2, 2, 0)
|
||||
@ -58,27 +61,29 @@ class MainApplication(GridFrame):
|
||||
def update(self, copycat):
|
||||
self.iterations += 1
|
||||
self.primary.update(copycat)
|
||||
temp = copycat.temperature.value()
|
||||
self.graph1.x += [self.iterations]
|
||||
self.graph1.y += [temp]
|
||||
#self.widgets['temp']['text'] = 'Temp:\n{}'.format(round(temp, 2))
|
||||
|
||||
slipnodes = copycat.slipnet.slipnodes
|
||||
codelets = copycat.coderack.codelets
|
||||
objects = copycat.workspace.objects
|
||||
|
||||
slipList = self.widgets['sliplist']
|
||||
slipList.delete(0, slipList.size())
|
||||
self.slipList.delete(0, self.slipList.size())
|
||||
slipnodes = sorted(slipnodes, key=lambda s:s.activation, reverse=True)
|
||||
for item in slipnodes:
|
||||
listStr = '{}: {}'.format(item.name, round(item.activation, 2))
|
||||
slipList.insert(tk.END, listStr)
|
||||
self.slipList.insert(tk.END, listStr)
|
||||
|
||||
codeletList = self.widgets['codeletlist']
|
||||
codeletList.delete(0, codeletList.size())
|
||||
self.codeletList.delete(0, self.codeletList.size())
|
||||
codelets = sorted(codelets, key=lambda c:c.urgency, reverse=True)
|
||||
for codelet in codelets:
|
||||
listStr = '{}: {}'.format(codelet.name, round(codelet.urgency, 2))
|
||||
codeletList.insert(tk.END, listStr)
|
||||
self.codeletList.insert(tk.END, listStr)
|
||||
|
||||
self.objectList.delete(0, self.objectList.size())
|
||||
#objects = sorted(objects, key=lambda c:c.urgency, reverse=True)
|
||||
for o in objects:
|
||||
#listStr = '{}: {}'.format(o.name, round(o.urgency, 2))
|
||||
listStr = str(o)
|
||||
self.objectList.insert(tk.END, listStr)
|
||||
|
||||
def reset_with_strings(self, initial, modified, target):
|
||||
self.primary.reset_with_strings(initial, modified, target)
|
||||
@ -97,7 +102,8 @@ class GUI(object):
|
||||
|
||||
def add_answers(self, answers):
|
||||
def modifier(status):
|
||||
plot_imbedded(answers, status)
|
||||
with plt.style.context(('dark_background')):
|
||||
plot_imbedded(answers, status)
|
||||
self.app.graph2.modifier = modifier
|
||||
|
||||
def refresh(self):
|
||||
|
||||
@ -40,15 +40,15 @@ class Status(object):
|
||||
self.y = []
|
||||
|
||||
def modifier(status):
|
||||
status.subplot.plot(status.x, status.y)
|
||||
with plt.style.context(('dark_background')):
|
||||
status.subplot.plot(status.x, status.y)
|
||||
|
||||
self.modifier = modifier
|
||||
self.update_plots(0)
|
||||
|
||||
def update_plots(self, i):
|
||||
self.subplot.clear()
|
||||
with plt.style.context(('dark_background')):
|
||||
self.modifier(self)
|
||||
self.modifier(self)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = tk.Tk()
|
||||
|
||||
Reference in New Issue
Block a user