forked from zietzm/Helmholtz_Test_Bench
Basic GUI framework
This commit is contained in:
@@ -94,3 +94,4 @@ ENV/
|
||||
|
||||
# VScode
|
||||
.vscode/
|
||||
*.pyc
|
||||
|
||||
+37
-8
@@ -1,11 +1,41 @@
|
||||
from tkinter import *
|
||||
|
||||
|
||||
class EmptyFrame:
|
||||
class HelmholtzGUI(Tk):
|
||||
|
||||
def __init__(self, window):
|
||||
frame = Frame(window, width=1000, height=600)
|
||||
frame.pack()
|
||||
def __init__(self):
|
||||
Tk.__init__(self)
|
||||
|
||||
self.Menu = TopMenu(self) # displays menu bar at the top
|
||||
|
||||
mainArea = Frame(self)
|
||||
mainArea.pack(fill="both", expand=True)
|
||||
|
||||
# mainArea.grid_rowconfigure(0, weight=1)
|
||||
# mainArea.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.frames = {} # dictionary for storing all pages
|
||||
|
||||
frame = EmptyFrame(mainArea)
|
||||
|
||||
self.frames[EmptyFrame] = frame
|
||||
|
||||
# frame.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
self.show_frame(EmptyFrame)
|
||||
|
||||
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)
|
||||
@@ -21,8 +51,7 @@ class TopMenu:
|
||||
|
||||
ModeSelector = Menu(menu)
|
||||
menu.add_cascade(label="Mode", menu=ModeSelector)
|
||||
ModeSelector.add_command(label="Full Manual", command=self.manual_mode(window))
|
||||
ModeSelector.add_command(label="Full Manual", command=self.manual_mode)
|
||||
|
||||
def manual_mode(self, window):
|
||||
print("Switching to manual mode")
|
||||
window.delete(ALL)
|
||||
def manual_mode(self):
|
||||
print("Switching to manual mode")
|
||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -18,5 +18,5 @@ global MAX_VOLTS
|
||||
|
||||
global ARDUINO
|
||||
|
||||
RELAY_PINS = [1, 2, 3] # digital pin on the Arduino for switching relay of each axis [x,y,z]
|
||||
RELAY_PINS = [15, 16, 17] # pin on the Arduino for switching relay of each axis [x,y,z]
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ g.Z_PORT = "COM2"
|
||||
# Code starts here------------------------------------------
|
||||
g.MAX_AMPS = np.sqrt(g.MAX_WATTS / g.RESISTANCES) # calculate maximum currents in each axis
|
||||
|
||||
mainWindow = Tk()
|
||||
MainFrame = ui.EmptyFrame(mainWindow)
|
||||
mainWindow = ui.HelmholtzGUI()
|
||||
Menu = ui.TopMenu(mainWindow)
|
||||
|
||||
mainWindow.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user