Made imports more consistent

This commit is contained in:
2021-08-02 22:21:29 +02:00
parent 4827d07b6d
commit 11b5ea4e36
9 changed files with 76 additions and 71 deletions
+12 -23
View File
@@ -17,11 +17,12 @@ import threading
from datetime import datetime
# import other project files:
import globals as g
import cage_func as func
import csv_threading as csv
import config_handling as config
import csv_logging as log
import src.globals as g
import src.cage_func as func
import src.csv_threading as csv
import src.config_handling as config
import src.csv_logging as log
from src.utility import ui_print
# define font styles:
HEADER_FONT = ("Arial", 13, "bold")
@@ -55,7 +56,7 @@ class HelmholtzGUI(Tk):
# switching between pages is done with show_frame() method
self.pages = {} # dictionary for storing all pages (different modes, displayed in main area)
for P in [ManualMode, Configuration, ExecuteCSVMode, ConfigureLogging]: # do this for every mode page
for P in [ManualMode, HardwareConfiguration, ExecuteCSVMode, ConfigureLogging]: # do this for every mode page
page = P(mainArea, self) # initialize the page with the mainArea frame as the parent
self.pages[P] = page # add the page to the dictionary
page.grid(row=0, column=0, sticky="nsew") # place all pages in the same place in the GUI
@@ -102,7 +103,7 @@ class TopMenu:
@staticmethod
def configuration(window): # switch to the settings page
window.show_frame(Configuration)
window.show_frame(HardwareConfiguration)
@staticmethod
def execute_csv_mode(window): # switch to the CSV execution page
@@ -459,7 +460,8 @@ class ExecuteCSVMode(Frame):
# More info: https://www.tutorialspoint.com/python/python_multithreading.htm
g.threadLock = threading.Lock() # create thread locking object, used to ensure all devices switch at once later
# create thread object:
self.csv_thread = csv.ExecCSVThread(self.sequence_array, self, self.controller)
self.csv_thread = csv.ExecCSVThread(self.sequence_array, self, self.controller, logging_enabled)
self.csv_thread.start() # start thread
def stop_run(self): # called on stop button press, interrupts sequence execution
@@ -499,8 +501,8 @@ class ExecuteCSVMode(Frame):
plotCanvas.get_tk_widget().grid(row=0, column=0, sticky="nesw") # place canvas in the UI
class Configuration(Frame):
# generate settings window to set program constants
class HardwareConfiguration(Frame):
"""Settings window to set program constants"""
# noinspection PyUnusedLocal
def __init__(self, parent, controller):
@@ -1125,16 +1127,3 @@ class OutputConsole(Frame):
# link scrollbar to the console
scrollbar.config(command=self.console.yview)
self.console.config(yscrollcommand=scrollbar.set)
def ui_print(*content): # prints text to built-in console, use exactly like normal print()
output = "" # initialize output as empty string
for text in content: # go through all elements to be printed
output = " ".join((output, str(text))) # add element to the output string
if not g.exitFlag: # application is still running --> output window is visible
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 console to bottom
else: # if window is not open, do normal print
print(output)