forked from zietzm/Helmholtz_Test_Bench
restructured program end, tried to fix threading issue on window close (not yet fixed)
This commit is contained in:
+21
-7
@@ -8,6 +8,7 @@ from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
||||
import numpy as np
|
||||
import os
|
||||
from os.path import exists
|
||||
import threading
|
||||
|
||||
import globals as g
|
||||
import cage_func as func
|
||||
@@ -519,8 +520,8 @@ class ExecuteCSVMode(Frame):
|
||||
self.parent = parent
|
||||
self.controller = controller # object on which mainloop() is running, usually main window
|
||||
# Functional init:
|
||||
self.csv_thread = None # the thread object for executing csv
|
||||
self.sequence_array = None # array containing the values from the csv file
|
||||
g.running = False # variable to turn thread execution on or off
|
||||
|
||||
# Build UI:
|
||||
self.grid_rowconfigure(ALL, weight=1)
|
||||
@@ -625,14 +626,13 @@ class ExecuteCSVMode(Frame):
|
||||
self.stop_button["state"] = "normal"
|
||||
self.reinit_button["state"] = "disabled"
|
||||
|
||||
# g.threadLock = threading.Lock()
|
||||
# g.threadLock = threading.Lock() # create thread locking object, used to ensure all devices switch at once later
|
||||
# create separate thread to run sequence execution in:
|
||||
g.running = True
|
||||
csv_thread = csv.ExecCSVThread("CSV_Thread", self.sequence_array, self, self.controller)
|
||||
csv_thread.start() # start thread
|
||||
self.csv_thread = csv.ExecCSVThread("CSV_Thread", self.sequence_array, self, self.controller)
|
||||
self.csv_thread.start() # start thread
|
||||
|
||||
def stop_run(self):
|
||||
g.running = False # this will cause the csv loop to end
|
||||
self.csv_thread.stop() # this will cause the csv loop to end
|
||||
# (de)activate buttons as needed:
|
||||
self.select_file_button["state"] = "normal"
|
||||
self.execute_button["state"] = "normal"
|
||||
@@ -654,6 +654,20 @@ class ExecuteCSVMode(Frame):
|
||||
plotCanvas.get_tk_widget().grid(row=0, column=0, sticky="nesw") # place canvas in UI
|
||||
|
||||
|
||||
class ConfigureLogging(Frame):
|
||||
# generate window to configure data logging
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.controller = controller # object on which mainloop() is running, usually main window
|
||||
|
||||
self.grid_rowconfigure(ALL, weight=1)
|
||||
self.grid_columnconfigure(ALL, weight=1)
|
||||
|
||||
row_counter = 0
|
||||
|
||||
|
||||
class StatusDisplay(Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
@@ -753,7 +767,7 @@ def ui_print(*content): # prints text to built in console
|
||||
output = ""
|
||||
for text in content:
|
||||
output = " ".join((output, str(text))) # append content
|
||||
if g.app is not None: # if main window is still open
|
||||
if not g.exitFlag:
|
||||
output = "".join(("\n", output)) # begin new line each time
|
||||
g.app.OutputConsole.console.insert(END, output) # print to console
|
||||
g.app.OutputConsole.console.see(END) # scroll to bottom
|
||||
|
||||
Reference in New Issue
Block a user