forked from zietzm/Helmholtz_Test_Bench
Status Panel setup
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
+77
-24
@@ -1,4 +1,11 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
import globals
|
||||
import cage_func
|
||||
import random as rand
|
||||
|
||||
NORM_FONT = ()
|
||||
SUB_HEADER_FONT = ("Arial", 9, "bold")
|
||||
|
||||
|
||||
class HelmholtzGUI(Tk):
|
||||
@@ -6,46 +13,35 @@ class HelmholtzGUI(Tk):
|
||||
def __init__(self):
|
||||
Tk.__init__(self)
|
||||
|
||||
Tk.wm_title(self, "Helmholtz Cage Control")
|
||||
Tk.wm_iconbitmap(self, "Helmholtz.ico")
|
||||
|
||||
self.Menu = TopMenu(self) # displays menu bar at the top
|
||||
|
||||
mainArea = Frame(self)
|
||||
mainArea.pack(fill="both", expand=True)
|
||||
mainArea.pack(side="top", fill="both", expand=True)
|
||||
|
||||
# mainArea.grid_rowconfigure(0, weight=1)
|
||||
# mainArea.grid_columnconfigure(0, weight=1)
|
||||
mainArea.grid_rowconfigure(0, weight=1)
|
||||
mainArea.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.frames = {} # dictionary for storing all pages
|
||||
|
||||
frame = EmptyFrame(mainArea)
|
||||
for F in (TestFrame, StatusDisplay):
|
||||
frame = F(mainArea, self)
|
||||
self.frames[F] = frame
|
||||
frame.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
self.frames[EmptyFrame] = frame
|
||||
|
||||
# frame.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
self.show_frame(EmptyFrame)
|
||||
self.show_frame(StatusDisplay)
|
||||
|
||||
def show_frame(self, key):
|
||||
frame = self.frames[key] # gets correct page from the dictionary
|
||||
frame.tkraise() # brings this frame to the front
|
||||
|
||||
|
||||
class EmptyFrame(Frame):
|
||||
|
||||
def __init__(self, parent):
|
||||
Frame.__init__(self, parent)
|
||||
|
||||
frame = Frame(parent, width=1000, height=600)
|
||||
frame.pack(padx=50, pady=50)
|
||||
|
||||
one = Label(frame, text="One", bg="red")
|
||||
one.pack(fill=X)
|
||||
two = Label(frame, text="Two", bg="blue")
|
||||
two.pack()
|
||||
|
||||
|
||||
class TopMenu:
|
||||
|
||||
def __init__(self, window):
|
||||
print("menu called")
|
||||
menu = Menu(window)
|
||||
window.config(menu=menu)
|
||||
|
||||
@@ -54,4 +50,61 @@ class TopMenu:
|
||||
ModeSelector.add_command(label="Full Manual", command=self.manual_mode)
|
||||
|
||||
def manual_mode(self):
|
||||
print("Switching to manual mode")
|
||||
print("Switching to manual mode")
|
||||
|
||||
|
||||
class TestFrame(Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
print("TestFrame called")
|
||||
|
||||
one = Label(self, text="One", bg="red")
|
||||
one.pack(fill=X)
|
||||
two = Label(self, text="Two", bg="blue")
|
||||
two.pack()
|
||||
button = ttk.Button(self, text="Print stuff", command=lambda: print_stuff("Hello"))
|
||||
button.pack()
|
||||
|
||||
|
||||
class StatusDisplay(Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
Frame.__init__(self, parent)
|
||||
print("StatusDisplay called") # ToDo: remove
|
||||
rowCounter = 0 # keep track of which row we are at in the grid layout
|
||||
|
||||
col = 0
|
||||
for header in ["X-Axis", "Y-Axis", "Z-Axis"]: # create Column headers
|
||||
headLabel = Label(self, text=header, font=SUB_HEADER_FONT)
|
||||
headLabel.grid(columnspan=2, row=rowCounter, column=col*2, sticky="ew")
|
||||
col = col + 1 # move to next column
|
||||
rowCounter = rowCounter + 1 # increase row counter to place future stuff below header
|
||||
|
||||
LabelTexts = ["Port:", "Channel:", "Output:"] # define content of row entries
|
||||
rowNo = len(LabelTexts) # get number of label rows
|
||||
columnNo = 3 # number of label columns
|
||||
Labels = [[] for _ in range(columnNo)]
|
||||
# prepare list of lists to contain all labels for row entries in all columns
|
||||
|
||||
for i in range(0, rowNo): # create label objects for row entries
|
||||
for j in range(columnNo):
|
||||
Labels[j].append(Label(self, text=LabelTexts[i]))
|
||||
|
||||
col = 0
|
||||
for LabelCol in Labels: # place row entries in grid layout for all columns
|
||||
for row in range(rowNo): # place row entries
|
||||
LabelCol[row].grid(row=row+rowCounter, column=col*2, sticky="w")
|
||||
col = col + 1
|
||||
rowCounter = rowCounter + rowNo # increase row counter to place future stuff below this
|
||||
|
||||
toBeRemoved = Label(self, text="Active TBD")
|
||||
toBeRemoved.grid(row=1, column=1)
|
||||
|
||||
|
||||
def print_stuff(stuff):
|
||||
print(stuff)
|
||||
|
||||
|
||||
def random_no():
|
||||
return rand.uniform(0, 20)
|
||||
|
||||
@@ -24,7 +24,5 @@ g.Z_PORT = "COM2"
|
||||
# Code starts here------------------------------------------
|
||||
g.MAX_AMPS = np.sqrt(g.MAX_WATTS / g.RESISTANCES) # calculate maximum currents in each axis
|
||||
|
||||
mainWindow = ui.HelmholtzGUI()
|
||||
Menu = ui.TopMenu(mainWindow)
|
||||
|
||||
mainWindow.mainloop()
|
||||
application = ui.HelmholtzGUI()
|
||||
application.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user