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