-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
149 lines (125 loc) · 4.68 KB
/
settings.py
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/python3
# Import 3rd party libraries ----------------------------------------
import tkinter as tk
import tkinter.font as font
# Import standard libraries -----------------------------------------
# Import application libraries --------------------------------------
import colors
from logger import BrewfermLogger
"""
Creates a rotating log
"""
logger = BrewfermLogger('settings.py').getLogger()
# -------------------------------------------------------------------
# Allow user to change system settings
# -------------------------------------------------------------------
class gMenu(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.create_widgets()
self.update_ok()
def create_widgets(self):
self.button_font = font.Font(family="Arial", size=-20, weight="bold")
self.target = tk.Button(
self.master.values_box,
text="Target Temp",
command=self.set_beer_target,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=self.button_font,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.sensor_assign = tk.Button(
self.master.values_box,
text="Assign",
command=self.assign_sensors,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=self.button_font,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.sensor_calibrate = tk.Button(
self.master.values_box,
text="Calibrate",
command=self.calibrate_sensors,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=self.button_font,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.bPIDsettings = tk.Button(
self.master.values_box,
text="Beer PID",
command=self.set_beer_pid,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=self.button_font,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.cPIDsettings = tk.Button(
self.master.values_box,
text="Chamber PID",
command=self.set_chamber_pid,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=self.button_font,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
def update_ok(self):
try:
self.after(500, self.update_ok)
except Exception as e:
logger.exception("%s %s", type(e), e)
def set_beer_target(self):
self.hide()
self.master.btemps.show_target()
def assign_sensors(self):
self.hide()
self.master.sensor_assign.show()
def calibrate_sensors(self):
self.hide()
self.master.sensor_calibrate.show()
def set_beer_pid(self):
self.hide()
self.master.bpid_settings.show()
def set_chamber_pid(self):
self.hide()
self.master.cpid_settings.show()
def hide(self):
self.target.place(x=0, y=0, height=0, width=0)
self.sensor_assign.place(x=0, y=0, height=0, width=0)
self.sensor_calibrate.place(x=0, y=0, height=0, width=0)
self.bPIDsettings.place(x=0, y=0, height=0, width=0)
self.cPIDsettings.place(x=0, y=0, height=0, width=0)
def show(self):
self.target.place(x=150, y=60, height=60, width=180)
self.bPIDsettings.place(x=370, y=60, height=60, width=180)
self.cPIDsettings.place(x=590, y=60, height=60, width=180)
self.sensor_assign.place(x=150, y=140, height=60, width=180)
self.sensor_calibrate.place(x=370, y=140, height=60, width=180)