forked from zietzm/Helmholtz_Test_Bench
Status display work, Error handling for not connected devices
This commit is contained in:
+43
-17
@@ -1,7 +1,7 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
import settings
|
||||
import cage_func
|
||||
import settings as g
|
||||
import cage_func as func
|
||||
import random as rand
|
||||
|
||||
NORM_FONT = ()
|
||||
@@ -19,7 +19,7 @@ class HelmholtzGUI(Tk):
|
||||
self.Menu = TopMenu(self) # displays menu bar at the top
|
||||
|
||||
mainArea = Frame(self)
|
||||
mainArea.pack(side="top", fill="both", expand=True)
|
||||
mainArea.pack(side="top", fill="both", expand=False)
|
||||
|
||||
mainArea.grid_rowconfigure(0, weight=1)
|
||||
mainArea.grid_columnconfigure(0, weight=1)
|
||||
@@ -81,25 +81,39 @@ class StatusDisplay(Frame):
|
||||
col = col + 1 # move to next column
|
||||
rowCounter = rowCounter + 1 # increase row counter to place future stuff below header
|
||||
|
||||
LabelTexts = ["Port:", "Channel:", "Output:"] # define content of row entries
|
||||
rowNo = len(LabelTexts) # get number of label rows
|
||||
columnNo = 3 # number of label columns
|
||||
Labels = [[] for _ in range(columnNo)]
|
||||
# prepare list of lists to contain all labels for row entries in all columns
|
||||
TextLabels = ["Port:", "Channel:", "Output:"] # define content of row entries
|
||||
self.rowNo = len(TextLabels) # get number of label rows
|
||||
|
||||
for i in range(0, rowNo): # create label objects for row entries
|
||||
for j in range(columnNo):
|
||||
Labels[j].append(Label(self, text=LabelTexts[i]))
|
||||
self.columnNo = 6 # number of label columns
|
||||
# prepare list of lists to contain all labels for row entries in all columns:
|
||||
self.Labels = [[] for _ in range(self.columnNo)]
|
||||
|
||||
self.label_dict = {}
|
||||
for name in TextLabels:
|
||||
self.label_dict[name] = [StringVar() for _ in range(int(self.columnNo/2))]
|
||||
for col in range(int(self.columnNo/2)):
|
||||
self.Labels[col*2].append(Label(self, text=name))
|
||||
self.Labels[col*2+1].append(Label(self, textvariable=self.label_dict[name][col]))
|
||||
|
||||
col = 0
|
||||
for LabelCol in Labels: # place row entries in grid layout for all columns
|
||||
for row in range(rowNo): # place row entries
|
||||
LabelCol[row].grid(row=row+rowCounter, column=col*2, sticky="w")
|
||||
for LabelCol in self.Labels: # place row entries in grid layout for all columns
|
||||
for row in range(self.rowNo): # place row entries
|
||||
LabelCol[row].grid(row=row+rowCounter, column=col, sticky="w")
|
||||
col = col + 1
|
||||
rowCounter = rowCounter + rowNo # increase row counter to place future stuff below this
|
||||
rowCounter = rowCounter + self.rowNo # increase row counter to place future stuff below this
|
||||
|
||||
toBeRemoved = Label(self, text="Active TBD")
|
||||
toBeRemoved.grid(row=1, column=1)
|
||||
self.update_labels(controller)
|
||||
|
||||
def update_labels(self, controller):
|
||||
i = 0
|
||||
for axis in g.AXES: # ToDo: switch to proper axes when PSU connected
|
||||
if axis.device is not None:
|
||||
axis.update_values()
|
||||
self.label_dict["Port:"][i].set(g.ports[i])
|
||||
self.label_dict["Channel:"][i].set(axis.channel)
|
||||
self.label_dict["Output:"][i].set(axis.output_active)
|
||||
i = i+1
|
||||
controller.after(2000, lambda: self.update_labels(controller))
|
||||
|
||||
|
||||
def print_stuff(stuff):
|
||||
@@ -108,3 +122,15 @@ def print_stuff(stuff):
|
||||
|
||||
def random_no():
|
||||
return rand.uniform(0, 20)
|
||||
|
||||
|
||||
class TestValues:
|
||||
def __init__(self):
|
||||
self.val1 = 0
|
||||
self.val2 = 0
|
||||
self.val3 = 0
|
||||
|
||||
def update_values(self):
|
||||
self.val1 = rand.uniform(0, 20)
|
||||
self.val2 = rand.uniform(0, 20)
|
||||
self.val3 = rand.uniform(0, 20)
|
||||
|
||||
Reference in New Issue
Block a user