forked from zietzm/Helmholtz_Test_Bench
Visual improvements for csv graphs
This commit is contained in:
+13
-15
@@ -279,7 +279,6 @@ class Configuration(Frame):
|
||||
self.file_select_frame.grid(row=row_counter, column=0, sticky=W, padx=20)
|
||||
|
||||
# Create and place buttons
|
||||
# ToDo: comments
|
||||
load_file_button = Button(self.file_select_frame, text="Load config file...", command=self.load_config,
|
||||
pady=5, padx=5, font=SMALL_BUTTON_FONT)
|
||||
load_file_button.grid(row=0, column=0, padx=5)
|
||||
@@ -299,17 +298,17 @@ class Configuration(Frame):
|
||||
port_frame.grid(row=row_counter, column=0, sticky=W)
|
||||
|
||||
entry_texts = ["XY PSU Serial Port:", "Z PSU Serial Port:"]
|
||||
self.XY_port = StringVar(value=g.XY_PORT)
|
||||
self.XY_port = StringVar(value=g.XY_PORT) # create variables to store the port names and set to current names
|
||||
self.Z_port = StringVar(value=g.Z_PORT)
|
||||
port_vars = [self.XY_port, self.Z_port]
|
||||
row = 0
|
||||
for text in entry_texts:
|
||||
field = Entry(port_frame, textvariable=port_vars[row])
|
||||
field = Entry(port_frame, textvariable=port_vars[row]) # create entry field
|
||||
field.grid(row=row, column=1, sticky=W)
|
||||
axis_label = Label(port_frame, text=text, padx=5, pady=10)
|
||||
axis_label.grid(row=row, column=0, sticky=W)
|
||||
unit_label = Label(port_frame, text="e.g. COM10")
|
||||
unit_label.grid(row=row, column=2, sticky=W)
|
||||
info_label = Label(port_frame, text="e.g. COM10")
|
||||
info_label.grid(row=row, column=2, sticky=W)
|
||||
row += 1
|
||||
|
||||
row_counter += 1
|
||||
@@ -514,7 +513,6 @@ class Configuration(Frame):
|
||||
|
||||
class ExecuteCSVMode(Frame):
|
||||
# generate configuration window to set program constants
|
||||
# ToDo (optional): Generate graph to show sequence to be executed
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
@@ -606,13 +604,13 @@ class ExecuteCSVMode(Frame):
|
||||
if exists(filename): # does the file exist?
|
||||
ui_print("File selected:", filename)
|
||||
try:
|
||||
self.sequence_array = csv.read_csv_to_array(filename)
|
||||
self.sequence_array = csv.read_csv_to_array(filename) # read array from csv
|
||||
except BaseException as e:
|
||||
ui_print("Error while opening file:", e)
|
||||
messagebox.showerror("Error!", "Error while opening file: \n%s" % e)
|
||||
|
||||
csv.check_array(self.sequence_array)
|
||||
self.display_plot()
|
||||
csv.check_array_ok(self.sequence_array) # check for values exceeding limits
|
||||
self.display_plot() # plot data and display
|
||||
|
||||
self.execute_button["state"] = "normal" # activate run button
|
||||
elif filename == '': # this happens when file selection window is closed without selecting a file
|
||||
@@ -641,8 +639,8 @@ class ExecuteCSVMode(Frame):
|
||||
self.stop_button["state"] = "disabled"
|
||||
self.reinit_button["state"] = "normal"
|
||||
|
||||
def display_plot(self): # ToDo: comments
|
||||
# calculate available height for plot:
|
||||
def display_plot(self):
|
||||
# calculate available height for plot (in pixels):
|
||||
height_others = 0
|
||||
for element in self.row_elements: # go through all rows in the widget except the plot frame
|
||||
height_others += element.winfo_height() # add up heights
|
||||
@@ -650,10 +648,10 @@ class ExecuteCSVMode(Frame):
|
||||
|
||||
width = min(self.parent.winfo_width() - 100, 1100) # set width to available space but max. 1100
|
||||
|
||||
figure = csv.plot_field_sequence(self.sequence_array, width, height)
|
||||
plotCanvas = FigureCanvasTkAgg(figure, self.plotFrame)
|
||||
plotCanvas.draw()
|
||||
plotCanvas.get_tk_widget().grid(row=0, column=0, sticky="nesw")
|
||||
figure = csv.plot_field_sequence(self.sequence_array, width, height) # create figure to be displayed
|
||||
plotCanvas = FigureCanvasTkAgg(figure, self.plotFrame) # create canvas to draw figure on
|
||||
plotCanvas.draw() # equivalent to matplotlib.show()
|
||||
plotCanvas.get_tk_widget().grid(row=0, column=0, sticky="nesw") # place canvas in UI
|
||||
|
||||
|
||||
class StatusDisplay(Frame):
|
||||
|
||||
Reference in New Issue
Block a user