-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
294 lines (222 loc) · 10.7 KB
/
settings.py
File metadata and controls
294 lines (222 loc) · 10.7 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
"""
classes to change OnStep settings
these write values directly to the controller, rather than saving
into the "app_data["variable"]" first -- the 'update' loops in the
main program update the screen.
the methods from tkSimpleDialog are used here as well as by
the classes in messagebox_dark.py
"""
import tkinter as tk
import tkSimpleDialog #edited for OnStep 'style'
import conversion
_bg='gray19'
_fg='tomato'
class Location(tkSimpleDialog.Dialog):
# Sites (locations) in the controller are numbered 0,1,2,3
# Site Names are indexed with M, N, O, & P
#
# We retrieve both at start-up...into app_data[] tk.StringVars
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Site [{}] - {}".format(self.parent.app_data["var_SiteNum"].get(), self.parent.app_data["var_SiteName"].get())).grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="Site number, 1-4: ").grid(row=1)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
limit = int(self.e1.get())-1 # input 1-4, sites numbered 0-3
#print(axis1, axis2) # or something
self.parent.scope.set_site(limit)
return None
# this method overrides the one in the Dialog class
def valid_input(self):
limit, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
if limit < 1 or limit > 4:
return False
return True # valid inputs
class Overhead_Limit(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Overhead limit [{}]".format(self.parent.scope.get_overhead_limit())).grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="Degrees, 60-90: ").grid(row=1)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
limit = int(self.e1.get())
#print(axis1, axis2) # or something
self.parent.scope.set_overhead_limit(str(limit))
return None
# this method overrides the one in the Dialog class
def valid_input(self):
limit, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
if limit < 60 or limit > 90:
return False
return True # valid inputs
class Horizon_Limit(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Horizon limit [{}]".format( self.parent.scope.get_horizon_limit() ) ).grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="Degrees, ±30: ").grid(row=1)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
limit = int(self.e1.get())
#print(axis1, axis2) # or something
self.parent.scope.set_horizon_limit(str(limit))
return None
# this method overrides the one in the Dialog class
def valid_input(self):
limit, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
if limit < -30 or limit > 30:
return False
return True # valid inputs
class PastE_Limit(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Past East limit [{}]".format(self.parent.scope.get_degrees_past_E())).grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="Degrees, ±180: ").grid(row=1)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
limit = int(self.e1.get())
#print(axis1, axis2) # or something
self.parent.scope.set_degrees_past_E(str(limit))
return None
# this method overrides the one in the Dialog class
def valid_input(self):
limit, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
if limit < -180 or limit > 180:
return False
return True # valid inputs
class PastW_Limit(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Past West limit [{}]".format(self.parent.scope.get_degrees_past_W())).grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="Degrees, ±180: ").grid(row=1)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
limit = int(self.e1.get())
#print(axis1, axis2) # or something
self.parent.scope.set_degrees_past_W(str(limit))
return None
# this method overrides the one in the Dialog class
def valid_input(self):
limit, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
if limit < -180 or limit > 180:
return False
return True # valid inputs
class Backlash_Settings(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Need BOTH entries, in arc-secs 0-3600").grid(row=0, columnspan=2)
tk.Label(parent, bg=_bg, fg=_fg, text="R/A Backlash [{}] Axis 1: ".format(self.parent.scope.get_backlash(1))).grid(row=1)
tk.Label(parent, bg=_bg, fg=_fg, text="DEC Backlash [{}] Axis 2: ".format(self.parent.scope.get_backlash(2))).grid(row=2)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e2 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e2.config(highlightbackground=self._bg, highlightthickness=0)
self.e2.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
self.e2.grid(row=2, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
axis1 = int(self.e1.get())
axis2 = int(self.e2.get())
#print(axis1, axis2) # or something
self.parent.app_data["var_Backlash1"].set(axis1)
self.parent.app_data["var_Backlash2"].set(axis2)
self.parent.scope.set_backlash(1,axis1)
self.parent.scope.set_backlash(2,axis2)
return None
# this method overrides the one in the Dialog class
def valid_input(self):
axis1, error_flag = conversion.str_to_int(self.e1.get())
if error_flag:
return False
axis2, error_flag = conversion.str_to_int(self.e2.get())
if error_flag:
return False
if axis1 < 0 or axis1 > 3600 or axis2 < 0 or axis2 > 3600:
return False
return True # valid inputs
class Coordinates_Settings(tkSimpleDialog.Dialog):
# this method overrides the one in the Dialog class
def body(self, parent, title, text):
tk.Label(parent, bg=_bg, fg=_fg, text="Need BOTH entries, 00:00:00 / ±00*00:00").grid(row=0, columnspan=2)
label_1 = tk.Label(parent, bg=_bg, fg=_fg, text="R/A : ")
label_1.grid(row=1)
label_2 = tk.Label(parent, bg=_bg, fg=_fg, text="DEC : ")
label_2.grid(row=2)
self.e1 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e1.insert(0, "{}".format(self.parent.scope.get_target_ra() ))
self.e1.config(highlightbackground=self._bg, highlightthickness=0)
self.e1.config(insertbackground='goldenrod1')
self.e2 = tk.Entry(parent, bg=self._bg, fg=self._fg)
self.e2.insert(0, "{}".format(self.parent.scope.get_target_de() ))
self.e2.config(highlightbackground=self._bg, highlightthickness=0)
self.e2.config(insertbackground='goldenrod1')
self.e1.grid(row=1, column=1)
self.e2.grid(row=2, column=1)
return self.e1 # initial focus
# this method overrides the one in the Dialog class
def apply(self):
axis1 = self.e1.get()
axis2 = self.e2.get()
print('ax1: {} ax2: {}'.format(axis1, axis2))
self.parent.app_data["var_TargetRA"].set(axis1)
self.parent.app_data["var_TargetDEC"].set(axis2)
self.parent.scope.set_target_ra(axis1)
self.parent.scope.set_target_de(axis2)
return None
# this method overrides the one in the Dialog class
def valid_input(self):
box_1 = self.e1.get()
box_2 = self.e2.get()
if not box_1 or not box_2: return False
ret_val = conversion.validate_hms(box_1)
if isinstance(ret_val, (float, str )):
## if we get a float or string, r/a is good
self.e1.delete(0, 'end')
self.e1.insert(0, "{}".format( ret_val ))
## now chek dec
ret_val = conversion.validate_dms(box_2)
if isinstance(ret_val, (float, str )):
self.e2.delete(0, 'end')
self.e2.insert(0, "{}".format( ret_val ))
return True # both are good
else:
return False
else:
return False