Status Panel Layout updates

This commit is contained in:
Martin Zietz
2021-01-22 18:00:23 +01:00
parent 03e3759525
commit 3e747cc5c6
+27 -16
View File
@@ -26,12 +26,15 @@ class HelmholtzGUI(Tk):
self.frames = {} # dictionary for storing all pages
for F in (TestFrame, StatusDisplay):
for F in [TestFrame]:
frame = F(mainArea, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StatusDisplay)
self.StatusDisplay = StatusDisplay(self, self)
self.StatusDisplay.pack(side="bottom", fill="x", expand=False)
self.show_frame(TestFrame)
def show_frame(self, key):
frame = self.frames[key] # gets correct page from the dictionary
@@ -70,38 +73,45 @@ class TestFrame(Frame):
class StatusDisplay(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
print("StatusDisplay called") # ToDo: remove
Frame.__init__(self, parent, relief=SUNKEN, bd=1)
self.grid_rowconfigure(ALL, weight=1)
self.grid_columnconfigure(ALL, weight=1)
rowCounter = 0 # keep track of which row we are at in the grid layout
x_pad = 10 # centrally set padding
col = 0
for header in ["X-Axis", "Y-Axis", "Z-Axis"]: # create Column headers
headLabel = Label(self, text=header, font=SUB_HEADER_FONT)
headLabel.grid(columnspan=2, row=rowCounter, column=col*2, sticky="ew")
for header in ["", "X-Axis", "Y-Axis", "Z-Axis"]: # create Column headers
headLabel = Label(self, text=header, font=SUB_HEADER_FONT, borderwidth=1,
relief="flat", anchor="w", padx=x_pad)
headLabel.grid(row=rowCounter, column=col, sticky="ew")
col = col + 1 # move to next column
rowCounter = rowCounter + 1 # increase row counter to place future stuff below header
# define content of row entries
TextLabels = ["Serial Port:", "PSU Channel:", "Connection Status:", "Output:", "Remote Control:",
"Voltage Setpoint:", "Actual Voltage:", "Current Setpoint:", "Actual Current:", " ",
TextLabels = ["PSU Serial Port:", "PSU Channel:", "Connection Status:", "", "Output:", "Remote Control:",
"Voltage Setpoint:", "Actual Voltage:", "Current Setpoint:", "Actual Current:", "",
"Target Field:", "Trgt. Field Raw:", "Target Current:", "Inverted:"]
self.rowNo = len(TextLabels) # get number of label rows
self.columnNo = 6 # number of label columns
self.columnNo = 4 # 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]))
self.label_dict[name] = [StringVar() for _ in range(self.columnNo-1)]
# add labels for row titles
self.Labels[0].append(Label(self, text=name, borderwidth=1, relief="flat", anchor="w", padx=x_pad))
for col in range(self.columnNo-1): # add labels vor values
self.Labels[col+1].append(Label(self, textvariable=self.label_dict[name][col],
borderwidth=1, relief="flat", anchor="w", padx=x_pad))
col = 0
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", padx=10)
LabelCol[row].grid(row=row+rowCounter, column=col, sticky="nsew")
col = col + 1
rowCounter = rowCounter + self.rowNo # increase row counter to place future stuff below this
@@ -112,7 +122,7 @@ class StatusDisplay(Frame):
for axis in g.AXES:
if axis.device is not None:
axis.update_values()
self.label_dict["Serial Port:"][i].set(g.ports[i])
self.label_dict["PSU Serial Port:"][i].set(g.ports[i])
self.label_dict["PSU Channel:"][i].set(axis.channel)
self.label_dict["Connection Status:"][i].set(axis.connected)
self.label_dict["Output:"][i].set(axis.output_active)
@@ -129,6 +139,7 @@ class StatusDisplay(Frame):
controller.after(2000, lambda: self.update_labels(controller))
# ToDo: remove
def print_stuff(stuff):
print(stuff)