forked from zietzm/Helmholtz_Test_Bench
added output console to ui
This commit is contained in:
+49
-18
@@ -32,8 +32,16 @@ class HelmholtzGUI(Tk):
|
||||
self.frames[F] = frame
|
||||
frame.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
self.StatusDisplay = StatusDisplay(self, self)
|
||||
self.StatusDisplay.pack(side="bottom", fill="x", expand=False)
|
||||
status_frame = Frame(self)
|
||||
status_frame.pack(side="bottom", fill="x", expand=False)
|
||||
status_frame.grid_rowconfigure(ALL, weight=1)
|
||||
status_frame.grid_columnconfigure(1, weight=1)
|
||||
|
||||
self.StatusDisplay = StatusDisplay(status_frame, self)
|
||||
self.StatusDisplay.grid(row=0, column=0, sticky="nesw")
|
||||
|
||||
self.OutputConsole = OutputConsole(status_frame)
|
||||
self.OutputConsole.grid(row=0, column=1, sticky="nesw")
|
||||
|
||||
self.show_frame(ManualMode)
|
||||
|
||||
@@ -66,7 +74,7 @@ class TestFrame(Frame): # ToDo: remove
|
||||
one.pack(fill=X)
|
||||
two = Label(self, text="Two", bg="blue")
|
||||
two.pack()
|
||||
button = ttk.Button(self, text="Print stuff", command=lambda: print("Hello"))
|
||||
button = ttk.Button(self, text="Print stuff", command=lambda: func.ui_print("Hello"))
|
||||
button.pack()
|
||||
|
||||
|
||||
@@ -130,14 +138,26 @@ class ManualMode(Frame):
|
||||
row_counter = row_counter + 1
|
||||
|
||||
# Setup execute button
|
||||
Label(self, text="").grid(row=row_counter, column=0) # add spacer
|
||||
row_counter = row_counter + 1
|
||||
execute_button = Button(self, text="Execute!", command=self.execute,
|
||||
pady=5, padx=5, font=BIG_BUTTON_FONT)
|
||||
execute_button.grid(row=row_counter, column=0, columnspan=2)
|
||||
self.buttons_frame = Frame(self)
|
||||
self.buttons_frame.grid_rowconfigure(ALL, weight=1)
|
||||
self.buttons_frame.grid_columnconfigure(ALL, weight=1)
|
||||
self.buttons_frame.grid_columnconfigure(2, weight=1, minsize=20)
|
||||
self.buttons_frame.grid(row=row_counter, column=0)
|
||||
|
||||
Label(self.buttons_frame, text="").grid(row=row_counter, column=0) # add spacer
|
||||
|
||||
execute_button = Button(self.buttons_frame, text="Execute!", command=self.execute,
|
||||
pady=5, padx=5, font=BIG_BUTTON_FONT)
|
||||
execute_button.grid(row=row_counter, column=0)
|
||||
|
||||
# add button for reinitialization
|
||||
reinit_button = Button(self.buttons_frame, text="Reinitialize", command=func.setup_axes,
|
||||
pady=5, padx=5, font=BIG_BUTTON_FONT)
|
||||
reinit_button.grid(row=row_counter, column=1)
|
||||
|
||||
# Add spacer to Frame below
|
||||
row_counter = row_counter + 1
|
||||
# Add spacer to Frame below
|
||||
|
||||
Label(self, text="", pady=10).grid(row=row_counter, column=0)
|
||||
|
||||
self.input_mode.trace_add('write', self.change_mode_callback) # call mode change function on dropdown change
|
||||
@@ -158,19 +178,19 @@ class ManualMode(Frame):
|
||||
|
||||
@staticmethod
|
||||
def execute_field(vector):
|
||||
print("field executing", vector)
|
||||
func.ui_print("field executing", vector)
|
||||
try:
|
||||
func.set_field_simple(vector*1e-6) # ToDo: change to set_field
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
func.ui_print(e)
|
||||
|
||||
@staticmethod
|
||||
def execute_current(vector):
|
||||
print("current executing:", vector)
|
||||
func.ui_print("current executing:", vector)
|
||||
try:
|
||||
func.set_current_vec(vector)
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
func.ui_print(e)
|
||||
|
||||
|
||||
class StatusDisplay(Frame):
|
||||
@@ -219,11 +239,6 @@ class StatusDisplay(Frame):
|
||||
col = col + 1
|
||||
# rowCounter = rowCounter + self.rowNo # increase row counter to place future stuff below this
|
||||
|
||||
# add button for reinitialization
|
||||
reinit_button = Button(self, text="Reinitialize", command=func.setup_axes,
|
||||
pady=5, padx=5, font=BIG_BUTTON_FONT)
|
||||
reinit_button.grid(row=0, column=self.columnNo+1, rowspan=3)
|
||||
|
||||
self.update_labels(controller)
|
||||
|
||||
def update_labels(self, controller):
|
||||
@@ -249,3 +264,19 @@ class StatusDisplay(Frame):
|
||||
self.label_dict["Inverted:"][i].set(axis.polarity_switched)
|
||||
i = i + 1
|
||||
controller.after(500, lambda: self.update_labels(controller))
|
||||
|
||||
|
||||
class OutputConsole(Frame):
|
||||
|
||||
def __init__(self, parent):
|
||||
Frame.__init__(self, parent, relief=SUNKEN, bd=1)
|
||||
|
||||
self.grid_rowconfigure(ALL, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1, minsize=60)
|
||||
|
||||
scrollbar = Scrollbar(self)
|
||||
self.console = Text(self)
|
||||
scrollbar.grid(row=0, column=1, sticky="ns")
|
||||
self.console.grid(row=0, column=0, sticky="nesw")
|
||||
scrollbar.config(command=self.console.yview)
|
||||
self.console.config(yscrollcommand=scrollbar.set)
|
||||
|
||||
Reference in New Issue
Block a user