-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench_computer.py
More file actions
101 lines (76 loc) · 3.62 KB
/
bench_computer.py
File metadata and controls
101 lines (76 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from tkinter import *
from tkinter.ttk import *
from tkinter import messagebox
PROGRAM_NAME = "Bench Controller"
class BenchComputer(Frame):
def __init__(self, root):
Frame.__init__(self, root)
root.protocol("WM_DELETE_WINDOW", self.on_closing) # This will create a pop-up to confirm ending the program, and
# if there is confirmation it will call the on_closing method
# to tidy up before closing.
self.pack(fill=BOTH,expand=True)
self.root = root
self.root.title(PROGRAM_NAME)
self.initUI()
def initUI(self):
self.root.update() #I call update in order to draw the root window so that I can take its dimensions
# in the next line.
# Create the notebook with three tabs
style = Style()
mygreen = "#d2ffd2"
myred = "#dd0202"
style.theme_create( "benchComputer",
parent="alt",
settings={
"TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0] } },
"TNotebook.Tab": {
"configure": {"padding": [10, 10], "background": mygreen },
"map": {"background": [("selected", myred)],
"expand": [("selected", [1, 1, 1, 0])] } } } )
style.theme_use("benchComputer")
##############################################################
# You can also customise the theme for each frame, like this:
# s = Style()
# s.configure('Tab1.TFrame', background='cyan')
# s.configure('Tab2.TFrame', background='red')
# s.configure('Tab3.TFrame', background='magenta')
# frame1 = Frame(width=400, height=300, style='Tab1.TFrame')
# frame2 = Frame(width=400, height=300, style='Tab2.TFrame')
# frame3 = Frame(width=400, height=300, style='Tab3.TFrame')
##############################################################
# Create the notebook UI
notebook = Notebook( self,
height = self.root.winfo_height(),
width = self.root.winfo_width()-150,
style = "large.TNotebook" )
frame1 = Frame()
frame2 = Frame()
frame3 = Frame()
notebook.add(frame1,text = "Instruments")
notebook.add(frame2,text = "Camera")
notebook.add(frame3,text = "Environment")
notebook.pack(pady = 5, side = LEFT)
#Create the log text area
log_label = Label(self,text="Log")
log_label.configure( background = "white",
width = 150,
justify = CENTER,
font = ("Helvetica", 14))
log_label.pack( side = TOP)
self.log_textBox = Text( self,
height = self.root.winfo_height(),
width = 150)
self.log_textBox.pack( side = RIGHT)
# Create the UI in the Control tab (frame1)
# Create the UI in the Camera tab (frame2)
# Create the UI in the Environment tab (frame3)
def on_closing(self):
if messagebox.askokcancel("Quit", "Do you want to quit?"):
self.root.destroy()
def main():
root = Tk()
root.attributes('-zoomed', True)
ex = BenchComputer(root)
root.mainloop()
if __name__ == '__main__':
main()