forked from zietzm/Helmholtz_Test_Bench
fit csv plot into window
This commit is contained in:
+16
-2
@@ -518,8 +518,8 @@ class ExecuteCSVMode(Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.controller = controller # object on which mainloop() is running, usually main window
|
||||
|
||||
# Functional init:
|
||||
self.sequence_array = None # array containing the values from the csv file
|
||||
g.running = False # variable to turn thread execution on or off
|
||||
@@ -529,9 +529,11 @@ class ExecuteCSVMode(Frame):
|
||||
self.grid_columnconfigure(ALL, weight=1)
|
||||
|
||||
row_counter = 0
|
||||
self.row_elements = [] # make list of elements in rows to calculate height available for plot
|
||||
|
||||
header = Label(self, text="Execute CSV Mode", font=HEADER_FONT, pady=3)
|
||||
header.grid(row=row_counter, column=0, padx=100, sticky=W)
|
||||
self.row_elements.append(header)
|
||||
|
||||
row_counter += 1
|
||||
|
||||
@@ -542,6 +544,8 @@ class ExecuteCSVMode(Frame):
|
||||
self.top_buttons_frame.grid_columnconfigure(ALL, weight=1)
|
||||
self.top_buttons_frame.grid(row=row_counter, column=0, sticky=W, padx=20)
|
||||
|
||||
self.row_elements.append(self.top_buttons_frame)
|
||||
|
||||
# Create and place buttons
|
||||
self.select_file_button = Button(self.top_buttons_frame, text="Select csv file...", command=self.load_csv,
|
||||
pady=5, padx=5, font=SMALL_BUTTON_FONT)
|
||||
@@ -565,6 +569,8 @@ class ExecuteCSVMode(Frame):
|
||||
self.checkbox_frame.grid_columnconfigure(ALL, weight=1)
|
||||
self.checkbox_frame.grid(row=row_counter, column=0, sticky=W, padx=20)
|
||||
|
||||
self.row_elements.append(self.checkbox_frame)
|
||||
|
||||
checkbox_label = Label(self.checkbox_frame, text="Disable device connection checks:")
|
||||
checkbox_label.grid(row=0, column=0, sticky=W, padx=3)
|
||||
self.xy_override = BooleanVar(value=False)
|
||||
@@ -636,7 +642,15 @@ class ExecuteCSVMode(Frame):
|
||||
self.reinit_button["state"] = "normal"
|
||||
|
||||
def display_plot(self): # ToDo: comments
|
||||
figure = csv.plot_field_sequence(self.sequence_array)
|
||||
# calculate available height for plot:
|
||||
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
|
||||
height = self.parent.winfo_height() - height_others - 50 # set to height of parent frame - other rows - margin
|
||||
|
||||
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")
|
||||
|
||||
+4
-2
@@ -103,9 +103,11 @@ def check_array(array):
|
||||
ui.ui_print(concerns)
|
||||
|
||||
|
||||
def plot_field_sequence(array): # ToDo: comments
|
||||
def plot_field_sequence(array, width, height): # ToDo: comments
|
||||
# ToDo: make pretty
|
||||
figure = plt.Figure(figsize=(8, 10), dpi=100)
|
||||
fig_dpi = 100
|
||||
px = 1/fig_dpi
|
||||
figure = plt.Figure(figsize=(width*px, height*px), dpi=fig_dpi)
|
||||
|
||||
# noinspection PyTypeChecker,SpellCheckingInspection
|
||||
axes = figure.subplots(3, sharex=True, sharey=True, gridspec_kw={'hspace': 0.4})
|
||||
|
||||
Reference in New Issue
Block a user