Fixes slipnode display
This commit is contained in:
1227
copycat.log
1227
copycat.log
File diff suppressed because it is too large
Load Diff
@ -10,13 +10,10 @@ from tkinter import filedialog
|
|||||||
|
|
||||||
class MainApplication(ttk.Frame):
|
class MainApplication(ttk.Frame):
|
||||||
MAX_COLUMNS = 10
|
MAX_COLUMNS = 10
|
||||||
MAX_ROWS = 4
|
|
||||||
|
|
||||||
def __init__(self, parent, *args, **kwargs):
|
def __init__(self, parent, *args, **kwargs):
|
||||||
ttk.Frame.__init__(self, parent, *args, **kwargs)
|
ttk.Frame.__init__(self, parent, *args, **kwargs)
|
||||||
self.widgets = dict()
|
self.widgets = dict()
|
||||||
self.slipnodes = []
|
|
||||||
self.slipwidgets = []
|
|
||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.create_widgets()
|
self.create_widgets()
|
||||||
@ -34,19 +31,19 @@ class MainApplication(ttk.Frame):
|
|||||||
self.widgets['temp'] = temp_label
|
self.widgets['temp'] = temp_label
|
||||||
|
|
||||||
def update_slipnodes(self, slipnodes):
|
def update_slipnodes(self, slipnodes):
|
||||||
for widget in self.slipwidgets:
|
slipnodes = [(node.name, round(node.activation, 2)) for node in slipnodes]
|
||||||
widget.grid_forget()
|
|
||||||
self.slipnodes = [(node.name, round(node.activation, 2)) for node in slipnodes]
|
|
||||||
row = 0
|
row = 0
|
||||||
for i, (name, amount) in enumerate(self.slipnodes):
|
for i, (name, amount) in enumerate(slipnodes):
|
||||||
column = i % MainApplication.MAX_COLUMNS
|
column = i % MainApplication.MAX_COLUMNS
|
||||||
if column == 0:
|
if column == 0 and i != 0:
|
||||||
row += 1
|
row += 1
|
||||||
if row + 1 >= MainApplication.MAX_ROWS:
|
text = text='{}\n({})'.format(name, amount)
|
||||||
break
|
if name not in self.widgets:
|
||||||
l = tk.Label(self, text='{}\n({})'.format(name, amount))
|
l = tk.Label(self, text=text)
|
||||||
l.grid(column=column, row=row+4, sticky=tk.SE)
|
l.grid(column=column, row=row+3, sticky=tk.SE)
|
||||||
self.slipwidgets.append(l)
|
self.widgets[name] = l
|
||||||
|
else:
|
||||||
|
self.widgets[name]['text'] = text
|
||||||
|
|
||||||
class GUI(object):
|
class GUI(object):
|
||||||
def __init__(self, title):
|
def __init__(self, title):
|
||||||
|
|||||||
Reference in New Issue
Block a user