-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterface2ccb.py.txt
2097 lines (1905 loc) · 113 KB
/
interface2ccb.py.txt
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#Original Code by Kingsley Baxter & Fiona Porter 2017 - See wiki for this version.
#Copy of existing interface with my own personal changes / Christian Chapman-Bird 2018
#--------------------------------------------------------------------------------------------------------------------
#This script handles the interface for the Lunar Radio Telescope (LRT). Ensure use with Python3 (and by extension,
# Spyder 3.x).
# The interface always has room for improvement, but currently consists of a navigation interface allowing for
#tracked observation of either a chosen object or a set of coordinates. Such an observation may be planned ahead
#of time with the observing scheduler feature - for a chosen number of hours (min. 1), telescope time may be
#scheduled in advance, and the handler will automatically perform the slew and track for as long as desired. The
#program MUST be left running for this to occur - leaving all windows open is highly recommended.
# If any issues should arise, first try restarting the computer and ensuring no connections are loose on the drive
#or PC. If problems persist, contact Christian Chapman-Bird at [email protected]. Happy observing!
# (all code is labelled with its respective author in the form /INITIALS)
#--------------------------------------------------------------------------------------------------------------------
import tkinter as tk
import tkinter.ttk as ttk
import time
import math
import ephem
import datetime
import serial
#The scheduleing feature of this interface uses the PyTables module. Therefore, it is important that the
#file 'Schedule_Base' is present in the home directory for data access and writing, or there will be trouble. /ccb
import tables
def runinterface():
#Initialise the interface.
menuscreen=tk.Tk()
# Setting up styles /fp
style = ttk.Style()
style.configure("Upper.TFrame", background="gray20")
style.configure("Lower.TFrame", background="white")
style.configure("Upper.TLabel", foreground="white", background="gray20", width=15, anchor=tk.CENTER)
style.configure("Lower.TLabel", foreground="black", background="white", width=15, anchor=tk.CENTER)
style.configure("WiderUpper.TLabel", foreground="white", background="gray20", width=18, anchor=tk.CENTER)
style.configure("WiderLower.TLabel", foreground="black", background="white", width=18, anchor=tk.CENTER)
style.configure("MiniUpper.TLabel", foreground="white", background="gray20", width=2, anchor=tk.W)
style.configure("MiniLower.TLabel", foreground="black", background="white", width=2, anchor=tk.W)
style.configure("ErrorLower.TLabel", foreground="black", background="white")
style.configure("Lower.TCheckbutton", background="white")
class ScheduleParams(tables.IsDescription):
#PyTables class. Important as without this no data can be saved. /ccb
startinghour = tables.IntCol()
finishinghour = tables.IntCol()
h_object = tables.StringCol(100)
author = tables.StringCol(100)
note = tables.StringCol(250)
track = tables.BoolCol()
chop = tables.BoolCol()
#Pop out the menu and set it up appropriately, in the centre of the screen /ccb
menuscreen.lift()
menuscreen.title("Telescope Interface")
menuscreen.resizable(0, 0)
menuscreen.columnconfigure(0,minsize=75)
menuscreen.columnconfigure(1,minsize=75)
menuw = 266
menuh = 70
menuscreenframe = ttk.Frame(menuscreen, width=menuw, height=menuh, style="Lower.TFrame")
menuscreenframe.tkraise()
scrwidth = menuscreen.winfo_screenwidth()
scrheight = menuscreen.winfo_screenheight()
centrex = scrwidth/2 - menuw/2
centrey = scrheight/2 - menuh/2
menuscreen.geometry('%dx%d+%d+%d'% (menuw,menuh,centrex,centrey))
#Buttons for the title menu - r-con interface could be implemented here /ccb
navbutton = tk.Button(menuscreen, text="Navigation Interface", width=15, height=5, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda: navigation_menu())
navbutton.grid(row=0,column=0)
radiobutton = tk.Button(menuscreen, text="Radio Control Interface", width=15, height=5, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda: print("Not yet implemented"))
radiobutton.grid(row=0,column=1)
def navigation_menu():
def rerunandquit():
# This function allows the program to rerun from the start, destroying all active tkinter windows
# Used for errors where the driver isn't connected - /fp
nodriverwindow.destroy()
mainnavinterface.destroy()
navigation_menu()
# Predefining a bunch of variables that are used later on to prevent error and speed up allocation
dataAZ = [0, 0, 0, 0]
dataEL = [0, 0, 0, 0]
NULL = chr(0)
today = datetime.date.today()
day = today.day
month = today.month
year = today.year
def editsch():
#Remove a newly-defunct schedule row from the table after observing is complete. /ccb
schedulefile = tables.open_file("Schedule_Base", mode = "a")
htable = getattr(schedulefile.root.schedules,'schedule_{}_{}_{}'.format(day,month,year))
htable.remove_rows(0,1)
htable.flush()
schedulefile.close()
def refreshsch():
#Import schedule data from file and pass to Tkinter for use elsewhere.
#This is done once per hour to ensure any updates made will be downloaded before their alloted time. /ccb
currentschedule=[]
schedulefile = tables.open_file("Schedule_Base", mode = "a")
schedulegroup = schedulefile.root.schedules
if schedulefile.__contains__('/schedules/schedule_{}_{}_{}'.format(day,month,year)) == False:
htable = schedulefile.create_table(schedulegroup,'schedule_{}_{}_{}'.format(day,month,year),
ScheduleParams,'{}-{}-{}_Schedule'.format(day,month,year))
else:
htable = getattr(schedulegroup,'schedule_{}_{}_{}'.format(day,month,year))
startinghours = [x['startinghour'] for x in htable.iterrows()]
finishinghours = [x['finishinghour'] for x in htable.iterrows()]
objects = [x['h_object'] for x in htable.iterrows()]
authors = [x['author'] for x in htable.iterrows()]
notes = [x['note'] for x in htable.iterrows()]
tracks = [x['track'] for x in htable.iterrows()]
chops = [x['chop'] for x in htable.iterrows()]
if startinghours != []:
for x in range(0,len(startinghours)):
currentschedule.append((int(startinghours[x]),int(finishinghours[x]),str(objects[x].decode('utf-8')),
str(authors[x].decode('utf-8')), str(notes[x].decode('utf-8')), bool(tracks[0]),bool(chops[0])))
sorted(currentschedule, key=lambda sched: sched[0])
mainnavinterface.schedule = currentschedule
mainnavinterface.after(60*60*1000,refreshsch)
def followsch():
#Follows the schedule at the requested time. Will wrap up the observing afterwards by stowing
#the telescope. /ccb
scheduletofollow = mainnavinterface.schedule
try:
schline = scheduletofollow[0]
except:
mainnavinterface.after(3600*1000,followsch)
return
if schline[0] == int(time.strftime("%H",time.gmtime())):
hourstoobserve = schline[1] - schline[0]
objchoice.set(schline[2])
if schline[6] == True:
mainnavinterface.chopchoice.set(True)
elif schline[6] == False and schline[5] == True:
objtrackchoice.set(True)
followingsch = True
print('Tracking should have started.')
statusupdate(objchoice,followingsch,hourstoobserve,is_obj=True)
mainnavinterface.after(hourstoobserve*3600*1000,lambda:[editsch,followsch,Stop_Drive])
else:
gostow()
mainnavinterface.after(3600*1000,followsch)
mainnavinterface = tk.Toplevel()
#Settings config - done with a basic text setup, not ideal but satisfactory for this minor task /ccb
settingsfile = open("settingsfile.txt","r")
all_lines = settingsfile.readlines()
defaulthomeaz = all_lines[0].rstrip()
defaulthomeel = all_lines[1].rstrip()
defaultstowaz = all_lines[2].rstrip()
defaultstowel = all_lines[3].rstrip()
mainnavinterface.chopdist = int(all_lines[4].rstrip())
mainnavinterface.chopperiod = int(all_lines[5].rstrip())
mainnavinterface.chopgrace = int(all_lines[6].rstrip())
settingsfile.close()
# Setting up all the Tkinter Variables, these act as global variables but I think they're a bit safer,
#also python is terrible at functions /kb
Az = tk.StringVar(mainnavinterface)
Az.set("0.0")
El = tk.StringVar(mainnavinterface)
El.set("0.0")
TarAZ = tk.StringVar(mainnavinterface)
TarAZ.set("0.0")
TarEL = tk.StringVar(mainnavinterface)
TarEL.set("0.0")
Already = tk.BooleanVar(mainnavinterface)
Already.set(True)
#Changed port to allow use with a Linux OS. /ccb
settingsfile = open("settingsfile.txt","r")
Server = serial.Serial()
Server.port = '/dev/ttyUSB0'
Server.baudrate = 460800
try:
Server.open()
except serial.serialutil.SerialException:
# Popup error if the driver isn't plugged in /fp
nodriverwindow = tk.Toplevel()
nodriverwindow.title("Error: No Driver")
nodriverwindow.lift()
nodriverframe = tk.Frame(nodriverwindow, background="white")
nodriverframe.columnconfigure(0, minsize=150)
nodriverframe.columnconfigure(1, minsize=150)
nodriverframe.rowconfigure(0, minsize=50)
nodriverframe.rowconfigure(1, minsize=50)
warning = tk.Label(nodriverframe, text="Error: driver not detected.\nPlease ensure the driver is connected to the "
"computer and turned on.", justify=tk.CENTER, background="white",
wraplength=150)
okbutton = tk.Button(nodriverframe, text="Retry", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda: rerunandquit())
exitbutton = tk.Button(nodriverframe, text="Quit", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda: nodriverwindow.destroy())
nodriverframe.grid(row=0, column=0, columnspan=2, rowspan=2)
warning.grid(row=0, column=0, columnspan=2)
okbutton.grid(row=1, column=0)
exitbutton.grid(row=1, column=1)
mainnavinterface.withdraw()
nodriverwindow.mainloop()
# The Rot2Prog protocol has three commands: Goto, Status, and Stop. Status and Stop don't require coordinate input
# So they can be defined now to improve efficiency in the program. See above for an explanation of the protocol. /kb
Stop_String = "W" + NULL * 10 + chr(15) + chr(32)
Stop_Command = Stop_String.encode('utf-8')
Read_String = "W" + NULL * 10 + chr(31) + chr(32)
Read_Command = Read_String.encode('utf-8')
#Defining some properties here for later use. /ccb
mainnavinterface.coord_statusupdate=""
mainnavinterface.errorflag=False
mainnavinterface.afterid=""
mainnavinterface.chopvar = False
mainnavinterface.chopflag = False
# The Stop function is the first one to be defined so that it can be inserted into future functions. /kb
def Stop_Drive():
#Stops the Drive
Server.write(Stop_Command)
#Cancel tracking when the drive is stopped /ccb
try:
mainnavinterface.after_cancel(mainnavinterface.afterid)
except ValueError:
pass
mainnavinterface.coord_statusupdate=""
mainnavinterface.chopvar = False
mainnavinterface.chopflag = False
# The read function, it sends the command and then reads the response. See above for a detailed breakdown of the
# response. Due to wanting the Drive to always move in a certain direction another function BetaSet_Drive() is called. /kb
def ReadFunction():
#Reads the current position of the drive and passes it back into tkinter.
Server.write(Read_Command)
Data = Server.read(11).decode('utf-8')
Bin = Server.read() #This seemingly unimportant variable is of paramount importance in drive operation.
#It clears the server output to read in the next az-el readout.
del Bin
DataAZ = Data[1:5] # The Azimuth is the 2nd through 5th character sent in the response
DataEL = Data[6:10] # The Elevation is the 6th through 10th character sent in the response
for e in range(0, 4):
dataAZ[e] = ord(DataAZ[e]) # converts the ascii character into a number since it uses ascii index 0-10 the
# number doesn't need to be manipulated further.
dataEL[e] = ord(DataEL[e])
Azimuth = ((dataAZ[0] * 1000 + dataAZ[1] * 100 + dataAZ[2] * 10 + dataAZ[3]) / 10) - 360
Elevation = ((dataEL[0] * 1000 + dataEL[1] * 100 + dataEL[2] * 10 + dataEL[3]) / 10) - 360
Azimuth = "{0:.1f}".format(Azimuth)
Elevation = "{0:.1f}".format(Elevation)
Az.set(Azimuth)
El.set(Elevation)
if Already.get() == False:
BetaSet_Drive()
mainnavinterface.after(50, ReadFunction) # Returns the two numbers so they can be displayed.
# Important function. Can't predefine the command since it changes with the coordinates. Will set an Azimuth and
# Elevation for the Drive to point at. /kb
def BetaSet_Drive():
# "This function is used when the Drive needs to move more than 180 degrees to make sure the drive goes the long
# way round."
Target = float(TarAZ.get())
Current = float(Az.get())
Comparison = Target - Current
if abs(Comparison) > 180:
return
AZ = Target
AZ = AZ + 360
AZ = str(AZ) # Its easier to split up a string then a number, at least to my knowledge.
if len(AZ) < 5:
AZ = (5 - len(AZ)) * "0" + AZ
AZhundreds = AZ[0] # Seperates the Digits out so that they can be read into their own byte.
AZtens = AZ[1]
AZdigits = AZ[2]
AZtenths = AZ[4]
EL = float(TarEL.get()) + 360
EL = str(EL) # Its easier to split up a string then a number, at least to my knowledge.
if len(EL) < 5:
EL = (5 - len(EL)) * "0" + AZ
ELhundreds = AZ[0] # Seperates the Digits out so that they can be read into their own byte.
ELtens = AZ[1]
ELdigits = AZ[2]
ELtenths = AZ[4]
ACC = chr(10) # The Accuracy of this driver is 0.1 Degrees Therefore to change the numbers from integers to floats
# a quotient of 10 is required.
COMMAND = chr(47) # Command 47 is the Set command, there are two others Read (31) and Stop (15).
END = chr(32) # The End of the transmission is marked by a space bar or ascii character 32.
Set_String = "W" + AZhundreds + AZtens + AZdigits + AZtenths + ACC + ELhundreds + ELtens + ELdigits + ELtenths + \
ACC + COMMAND + END # The culmination of the processes above are fed into this string.
Set_Command = Set_String.encode('utf-8') # Which is then encoded into byte information to be sent.
Server.write(Stop_Command)
time.sleep(0.1)
Server.write(Set_Command)
Already.set(True)
# Most important function will take in an Az El and make the drive turn to that location. Its pretty robust with the
# error messages above. Needs BetaSet_Drive to function due to the BREAK part of the code. Important thing about this
# code is that the Tkinter variables are the key. They are used as checks and balances. Make sure they are all there or
# that all reference to them is gone otherwise problems will occur. /kb
def Set_Drive(AZInput, ELInput):
"Drives the Drive to a set Azimuth and Elevation"
BREAK = float(Az.get()) + 179
BREAK2 = float(Az.get()) - 179
try:
AZ = float(AZInput) # Converts the string to a Float for numerical manipulation
EL = float(ELInput)
except ValueError:
return
if (EL < -0) or (EL > 90):
return
if (AZ < 0) or (AZ > 360):
return
TarAZ.set(str(AZ))
TarEL.set(str(EL))
if AZ > BREAK:
AZ = BREAK
Already.set(False)
elif AZ < BREAK2:
AZ = BREAK2
Already.set(False)
# The controller can't take negative number so all number are increased by 360 degrees
EL = EL + 360
AZ = AZ + 360
AZ = str(AZ) # Its easier to split up a string then a number, at least to my knowledge.
if len(AZ) < 5:
AZ = (5 - len(AZ)) * "0" + AZ
EL = str(EL)
if len(EL) < 5:
EL = (5 - len(EL)) * "0" + AZ
AZhundreds = AZ[0] # Seperates the Digits out so that they can be read into their own byte.
AZtens = AZ[1]
AZdigits = AZ[2]
AZtenths = AZ[4]
ELhundreds = EL[0] # Same for Elevation as Azimuth
ELtens = EL[1]
ELdigits = EL[2]
ELtenths = EL[4]
ACC = chr(10) # The Accuracy of this driver is 0.1 Degrees Therefore to change the numbers from integers to floats
# a quotient of 10 is required.
COMMAND = chr(47) # Command 47 is the Set command, there are two others Read (31) and Stop (15).
END = chr(32) # The End of the transmission is marked by a space bar or ascii character 32.
Set_String = "W" + AZhundreds + AZtens + AZdigits + AZtenths + ACC + ELhundreds + ELtens + ELdigits + ELtenths + \
ACC + COMMAND + END # The culmination of the processes above are fed into this string.
Set_Command = Set_String.encode('utf-8') # Which is then encoded into byte information to be sent.
Server.write(Set_Command)
# Establish the telescope's location for ephem
# Coordinates here are those for the telescope site as given by Google Maps /fp
mylocation = ephem.Observer()
mylocation.long, mylocation.lat = '-4.307077', '55.902429'
def todms(inputangle):
# Converter between angles in fractional degrees and dms; produces output string for the interface coordinates /fp
# Separate out degrees, minutes and seconds, initially as ints or floats
degree = math.floor(inputangle)
firstremainder = inputangle-degree
minute = math.floor(firstremainder*60)
secondremainder = (firstremainder*60)-minute
second = round(secondremainder*60, 1)
# The rounding sometimes causes the seconds value to appear as 60; this corrects it
if second == 60:
second = 0
minute = minute + 1
degformat = "{0:0=3d}°".format(degree)
minformat = "{0:0=2d}m".format(minute)
secformat = "{0:04.1f}s".format(second)
coord = "{} {} {}".format(degformat, minformat, secformat)
return coord
# Clock in UTC; updates every 500ms
# Note: this isn't the clock used in ephem calculations, so it's not intended to be especially precise /fp
def tick():
timenow = time.strftime("%H:%M:%S", time.gmtime())
clock.config(text=timenow)
clock.after(500, tick)
def getlocation():
# Get current az-el from driver
# Convert to ra-dec
# Produce four labels for az-el and ra-dec coordinates
# Update this periodically - 50ms /fp
aznow = float(Az.get()) # placeholder
elnow = float(El.get()) # placeholder
mylocation.date = datetime.datetime.utcnow()
[rarad, decrad] = mylocation.radec_of(math.radians(aznow), math.radians(elnow))
ranow = math.degrees(rarad)
decnow = math.degrees(decrad)
azcoord = todms(aznow)
elcoord = todms(elnow)
racoord = todms(ranow)
deccoord = todms(decnow)
azval.config(text=azcoord)
elval.config(text=elcoord)
raval.config(text=racoord)
decval.config(text=deccoord)
decval.after(50, getlocation)
def gohome():
# Home the telescope. /ccb
homeazfloat = float(homeaz.get())
homeelfloat = float(homeel.get())
Set_Drive(homeazfloat, homeelfloat)
def gostow():
# Stow the telescope. /ccb
stowazfloat = float(stowaz.get())
stowelfloat = float(stowel.get())
Set_Drive(stowazfloat, stowelfloat)
def mainquit():
# Quit function: Now properly closes the port when exiting the interface. /ccb
mainnavinterface.destroy()
Server.close()
def stowandquit():
# Special case of the stow command that also quits the interface. /ccb
stowazfloat = float(stowaz.get())
stowelfloat = float(stowel.get())
Set_Drive(stowazfloat, stowelfloat)
mainquit()
def stowcheck():
# Offers a prompt to drive the telescope to the stow position before shutting the interface /fp
checkAz = float(Az.get())
checkEl = float(El.get())
if checkAz == float(stowaz.get()) and checkEl == float(stowel.get()):
mainquit()
return
stowwindow = tk.Toplevel()
stowwindow.title("Stow?")
stowframe = ttk.Frame(stowwindow, style="Lower.TFrame")
stoww=300
stowh=100
stowx=int(scrwidth/2-stoww/2)
stowy=int(scrheight/2-stowh/2)
stowwindow.geometry('{}x{}+{}+{}'.format(stoww, stowh, stowx, stowy))
stowframe.columnconfigure(0, minsize=150)
stowframe.columnconfigure(1, minsize=150)
stowframe.rowconfigure(0, minsize=50)
stowframe.rowconfigure(1, minsize=50)
warning = ttk.Label(stowframe, text="Stow the telescope before quitting?", justify=tk.CENTER,
style="ErrorLower.TLabel", wraplength=150)
okbutton = tk.Button(stowframe, text="Yes", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda:[stowandquit(),stowwindow.destroy()])
exitbutton = tk.Button(stowframe, text="No", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue",
command=lambda:[mainquit(),stowwindow.destroy()])
stowframe.grid(row=0, column=0, columnspan=2, rowspan=2)
warning.grid(row=0, column=0, columnspan=2)
okbutton.grid(row=1, column=0)
exitbutton.grid(row=1, column=1)
stowwindow.mainloop()
def missinginputerror(problemphrase):
# This error message appears when information is missing
# The "problemphrase" input allows for a custom message to be displayed for each different error /fp
mainnavinterface.errorflag=True
errorwindow = tk.Toplevel()
errorwindow.title("Error")
errorwindow.lift()
errorframe = ttk.Frame(errorwindow, style="Lower.TFrame")
errorframe.columnconfigure(0, minsize=200)
errorframe.rowconfigure(0, minsize=50)
errorframe.rowconfigure(1, minsize=50)
warning = ttk.Label(errorframe, text="Error: missing input.\nPlease select " + problemphrase, justify=tk.CENTER,
style="ErrorLower.TLabel", wraplength=150)
okbutton = tk.Button(errorframe, text="OK", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue", command=errorwindow.destroy)
errorframe.grid(row=0, column=0)
warning.grid(row=0, column=0)
okbutton.grid(row=1, column=0)
def invalidinputerror(problemphrase):
# This error message appears when input isn't valid - for example, text in a field that expects numbers
# The "problemphrase" input allows for a custom message to be displayed for each different error /fp
mainnavinterface.errorflag=True
errorwindow = tk.Toplevel()
errorwindow.title("Error")
errorwindow.lift()
errorframe = ttk.Frame(errorwindow, style="Lower.TFrame")
errorframe.columnconfigure(0, minsize=200)
errorframe.rowconfigure(0, minsize=50)
errorframe.rowconfigure(1, minsize=50)
warning = ttk.Label(errorframe, text="Error: invalid input.\nPlease input " + problemphrase, justify=tk.CENTER,
style="ErrorLower.TLabel", wraplength=150)
okbutton = tk.Button(errorframe, text="OK", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue", command=errorwindow.destroy)
errorframe.grid(row=0, column=0)
warning.grid(row=0, column=0)
okbutton.grid(row=1, column=0)
def coordunavailableerror():
# This accounts for coordinates being below the horizon and prevents attempts to drive there. /fp
mainnavinterface.errorflag = True
errorwindow = tk.Toplevel()
errorwindow.title("Error")
errorwindow.lift()
errorframe = ttk.Frame(errorwindow, style="Lower.TFrame")
errorframe.columnconfigure(0, minsize=200)
errorframe.rowconfigure(0, minsize=50)
errorframe.rowconfigure(1, minsize=50)
warning = ttk.Label(errorframe, text="Error: coordinates unavailable.\nThis point is currently below the "
"horizon.", justify=tk.CENTER, style="ErrorLower.TLabel", wraplength=150)
okbutton = tk.Button(errorframe, text="OK", width=12, height=1, wraplength=70,
background="light sky blue", activebackground="deep sky blue", command=errorwindow.destroy)
errorframe.grid(row=0, column=0)
warning.grid(row=0, column=0)
okbutton.grid(row=1, column=0)
def schedule_startup():
#Schedule handler. /ccb
def saveobsslot(day,month,year,starthr,endhr,chosen_obj,author,note,track,chop):
#Saves a chosen observation slot in the schedule.
#Error Handling.
try:
int(starthr)
pass
except:
invalidinputerror("a valid starting time.")
return
try:
int(endhr)
pass
except:
invalidinputerror("a valid finish time.")
return
if int(starthr) > int(endhr):
invalidinputerror("a forward-running time period.")
return
if int(starthr) < 0 or int(starthr) > 23:
invalidinputerror("a valid starting time")
return
if int(endhr) < 0 or int(endhr) > 23:
invalidinputerror("a valid finishing time")
return
if chosen_obj == "":
invalidinputerror("an object.")
return
if author == "":
invalidinputerror("an author.")
return
if note == "":
invalidinputerror("a descriptive note.")
return
#Open up the PyTables file and input the given schedule details.
schedulefile = tables.open_file("Schedule_Base", mode = "a")
#Schedule group in case of file loss.
#schedulegroup = schedulefile.create_group("/",'schedules','Schedule Info')
schedulegroup = schedulefile.root.schedules
if schedulefile.__contains__('/schedules/schedule_{}_{}_{}'.format(day,month,year)) == False:
htable = schedulefile.create_table(schedulegroup,'schedule_{}_{}_{}'.format(day,month,year),
ScheduleParams,'{}-{}-{}_Schedule'.format(day,month,year))
else:
htable = getattr(schedulegroup,'schedule_{}_{}_{}'.format(day,month,year))
rowpoint = htable.row
rowpoint['startinghour'] = int(starthr)
rowpoint['finishinghour'] = int(endhr)
rowpoint['h_object'] = chosen_obj
rowpoint['author'] = author
rowpoint['note'] = note
rowpoint['track'] = track
rowpoint['chop'] = chop
#Save the changes, flush the table and close up.
rowpoint.append()
htable.flush()
schedulefile.close()
#Rerun the date checker to update the interface.
enterdate(day,month,year)
def enterdate(day,month,year):
#Changes the interface to another day, and updates the schedule to match.
def redden(numtoredden):
#Turn numbers red.
buttontochange = schwin.nametowidget("schframe.hour_{}".format(numtoredden))
buttontochange.config(background='red')
def greenen(numtogreenen):
#Turn numbers green.
buttontochange = schwin.nametowidget("schframe.hour_{}".format(numtogreenen))
buttontochange.config(background='green')
#Open the schedule file.
schedulefile = tables.open_file("Schedule_Base", mode = "a")
#Try to open the table file. If it doesn't exist, no schedule has been made so it must be blank.
try:
htable = getattr(schedulefile.root.schedules,'schedule_{}_{}_{}'.format(day,month,year))
startinghours = [x['startinghour'] for x in htable.iterrows()]
finishinghours = [x['finishinghour'] for x in htable.iterrows()]
for x in range(0,24):
greenen(x)
for y in range(0,len(startinghours)):
for x in range(startinghours[y],finishinghours[y]+1):
redden(x)
schedulefile.close()
except:
for x in range(0,24):
greenen(x)
def displayschinfo(event,pressedno):
#Shows the info of the schedule, and allows removal of the scheduled obs.
#Open and centre the screen.
schinfowin = tk.Toplevel()
schinfowin.title("Schedule Info")
schinfowin.resizable(0,0)
schw = 400
schh = 200
schx = scrwidth/2 - schw/2
schy = scrheight/2 - schh/2 -200
schinfowin.geometry('%dx%d+%d+%d'% (schw,schh,schx,schy))
[day,month,year] = dy_ent.get(),mo_ent.get(),yr_ent.get()
state = []
def greenen(numtogreenen):
#Turn numbers green.
buttontochange = schwin.nametowidget("schframe.hour_{}".format(numtogreenen))
buttontochange.config(background='green')
def yellowen(numtoyellowen):
#Turn numbers yellow.
buttontochange = schwin.nametowidget("schframe.hour_{}".format(numtoyellowen))
buttontochange.config(background='yellow')
def redden(numtoredden):
#Turn numbers red.
buttontochange = schwin.nametowidget("schframe.hour_{}".format(numtoredden))
buttontochange.config(background='red')
def removeselectedobs(day,month,year,schedulefile,pressedno):
#Remove the selected observation booking.
try:
htable = getattr(schedulefile.root.schedules,'schedule_{}_{}_{}'.format(day,month,year))
starthrscheck = [x['startinghour'] for x in htable.iterrows()]
finhrscheck = [x['finishinghour'] for x in htable.iterrows()]
for x in range(0,len(starthrscheck)):
if starthrscheck[x] <= pressedno and finhrscheck[x] >= pressedno:
indextoremove = x
selectedstart = starthrscheck[x]
selectedfin = finhrscheck[x]
htable.remove_rows(indextoremove,indextoremove+1)
htable.flush()
for x in range(selectedstart,selectedfin+1):
greenen(x)
schedulefile.close()
schinfowin.destroy()
except:
print('no chance, mate')
#Open the PyTables file, and grab the schedule info from it.
schedulefile = tables.open_file("Schedule_Base", mode = "a")
try:
htable = getattr(schedulefile.root.schedules,'schedule_{}_{}_{}'.format(day,month,year))
startinghours = [x['startinghour'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
finishinghours = [x['finishinghour'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
objects = [x['h_object'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
authors = [x['author'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
notes = [x['note'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
tracks = [x['track'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
chops = [x['chop'] for x in htable.iterrows()
if x['startinghour'] <= pressedno and x['finishinghour'] >= pressedno]
#If all is ok, display the schedule information accordingly.
for x in range(int(startinghours[0]),int(finishinghours[0])+1):
yellowen(x)
if startinghours == []:
state = ['Unbooked']
[startinghours,finishinghours,objects,notes,authors,tracks,chops] = [[''],[''],[''],[''],[''],[''],['']]
else:
state = ['Booked']
except:
#If nothing is found, there cannot be a booking here.
state=['Unbooked']
startinghours = ['']
finishinghours = ['']
objects = ['']
authors = ['']
notes = ['']
tracks = ['']
chops = ['']
#Widgets. Messy but there's no getting around it.
schinfo_statelb = tk.Label(schinfowin,text=state[0])
schinfo_statelb.pack(fill=tk.BOTH)
schinfo_strthrlb = tk.Label(schinfowin,text="Starting Hour: "+str(startinghours[0]),width=30)
schinfo_strthrlb.pack(fill=tk.BOTH)
schinfo_finhrlb = tk.Label(schinfowin,text="Finishing Hour: "+str(finishinghours[0]),width=30)
schinfo_finhrlb.pack(fill=tk.BOTH)
try:
schinfo_objlb = tk.Label(schinfowin,text="Object: "+str(objects[0].decode('utf-8')),width=30)
except AttributeError:
schinfo_objlb = tk.Label(schinfowin,text="Object: "+str(objects[0]),width=30)
schinfo_objlb.pack(fill=tk.BOTH)
try:
schinfo_authlb = tk.Label(schinfowin,text="Author: "+str(authors[0].decode('utf-8')),width=30)
except AttributeError:
schinfo_authlb = tk.Label(schinfowin,text="Author: "+str(authors[0]),width=30)
schinfo_authlb.pack(fill=tk.BOTH)
try:
schinfo_notelb = tk.Label(schinfowin,text="Schedule Note: "+str(notes[0].decode('utf-8')),width=30)
except:
schinfo_notelb = tk.Label(schinfowin,text="Schedule Note: "+str(notes[0]),width=30)
schinfo_notelb.pack(fill=tk.BOTH)
schinfo_slewtypelb = tk.Label(schinfowin,text="Method: Static",width=30)
if chops[0] == True:
schinfo_slewtypelb.config(text="Method: Chopping")
elif chops[0] == False and tracks[0] == True:
schinfo_slewtypelb.config(text="Method: Tracking")
schinfo_slewtypelb.pack(fill=tk.BOTH)
schinfo_ok = tk.Button(schinfowin,text="Ok",
command = lambda:closeschinfo(startinghours,finishinghours,schedulefile),
height = 5)
schinfo_ok.pack(fill=tk.X)
if startinghours != ['']:
schinfo_remove = tk.Button(schinfowin,text="Remove",
command = lambda:removeselectedobs(day,month,year,schedulefile,pressedno),
height = 3)
schinfo_remove.pack(fill=tk.X)
else:
schinfo_ok.config(height=9)
def closeschinfo(starthrs,finhrs,filetoclose):
try:
for x in range(starthrs[0],finhrs[0]+1):
redden(x)
except:
pass
filetoclose.close()
schinfowin.destroy()
#On exit, close up properly and re-redden the numbers selected if necessary.
schinfowin.protocol("WM_DELETE_WINDOW", lambda: closeschinfo(startinghours,finishinghours,schedulefile))
schinfowin.mainloop()
#Base window setup. Again, messy but it needs to be done. Multiple frames and pack could have been
#used but this works just as well and offers additional customisation below.
schwin = tk.Toplevel()
schwin.title("Observing Schedule <IN UTC>")
schwin.resizable(0,0)
schwin.columnconfigure(0,minsize=2)
schwin.columnconfigure(1,minsize=2)
schwin.columnconfigure(2,minsize=2)
schwin.columnconfigure(3,minsize=2)
schwin.columnconfigure(4,minsize=2)
schwin.columnconfigure(5,minsize=2)
schwin.columnconfigure(6,minsize=2)
schwin.columnconfigure(7,minsize=2)
schwin.columnconfigure(8,minsize=2)
schwin.columnconfigure(9,minsize=2)
schwin.columnconfigure(10,minsize=2)
schwin.columnconfigure(11,minsize=2)
schwin.columnconfigure(12,minsize=2)
schwin.columnconfigure(13,minsize=2)
schwin.columnconfigure(14,minsize=2)
schwin.columnconfigure(15,minsize=2)
schwin.columnconfigure(16,minsize=2)
schwin.columnconfigure(17,minsize=2)
schwin.columnconfigure(18,minsize=2)
schwin.columnconfigure(19,minsize=2)
schwin.columnconfigure(20,minsize=2)
schwin.columnconfigure(21,minsize=2)
schwin.columnconfigure(22,minsize=2)
schwin.columnconfigure(23,minsize=2)
schwin.rowconfigure(0,minsize=5)
schwin.rowconfigure(1,minsize=5)
schwin.rowconfigure(2,minsize=5)
schwin.rowconfigure(3,minsize=5)
schwin.rowconfigure(4,minsize=5)
#Open in the middle of the screen.
scrwidth = schwin.winfo_screenwidth()
scrheight = schwin.winfo_screenheight()
schw = 436
schh = 170
schx = scrwidth/2 - schw/2
schy = scrheight/2 - schh/2
schwin.geometry('%dx%d+%d+%d'% (schw,schh,schx,schy))
schframe = tk.Frame(schwin,name="schframe")
schframe.grid(row=0,column=0,rowspan=3,columnspan=24)
#Separators for a neater inteface
horizline1 = ttk.Separator(schframe,orient=tk.HORIZONTAL)
horizline1.grid(row=1,column=0,columnspan=24,sticky=tk.N+tk.E+tk.S+tk.W)
horizline2 = ttk.Separator(schframe,orient=tk.HORIZONTAL)
horizline2.grid(row=3,column=0,columnspan=24,sticky=tk.N+tk.E+tk.S+tk.W)
#All the Hour labels defined here and setup for double-click routine
hour_0 = tk.Label(schframe,text="0",width=2,background='green',name="hour_0")
hour_0.grid(row=2,column=0)
hour_0.bind("<Double-Button-1>",lambda event:displayschinfo(event,0))
hour_1 = tk.Label(schframe,text="1",width=2,background='green',name="hour_1")
hour_1.grid(row=2,column=1)
hour_1.bind("<Double-Button-1>",lambda event:displayschinfo(event,1))
hour_2 = tk.Label(schframe,text="2",width=2,background='green',name="hour_2")
hour_2.grid(row=2,column=2)
hour_2.bind("<Double-Button-1>",lambda event:displayschinfo(event,2))
hour_3 = tk.Label(schframe,text="3",width=2,background='green',name="hour_3")
hour_3.grid(row=2,column=3)
hour_3.bind("<Double-Button-1>",lambda event:displayschinfo(event,3))
hour_4 = tk.Label(schframe,text="4",width=2,background='green',name="hour_4")
hour_4.grid(row=2,column=4)
hour_4.bind("<Double-Button-1>",lambda event:displayschinfo(event,4))
hour_5 = tk.Label(schframe,text="5",width=2,background='green',name="hour_5")
hour_5.grid(row=2,column=5)
hour_5.bind("<Double-Button-1>",lambda event:displayschinfo(event,5))
hour_6 = tk.Label(schframe,text="6",width=2,background='green',name="hour_6")
hour_6.grid(row=2,column=6)
hour_6.bind("<Double-Button-1>",lambda event:displayschinfo(event,6))
hour_7 = tk.Label(schframe,text="7",width=2,background='green',name="hour_7")
hour_7.grid(row=2,column=7)
hour_7.bind("<Double-Button-1>",lambda event:displayschinfo(event,7))
hour_8 = tk.Label(schframe,text="8",width=2,background='green',name="hour_8")
hour_8.grid(row=2,column=8)
hour_8.bind("<Double-Button-1>",lambda event:displayschinfo(event,8))
hour_9 = tk.Label(schframe,text="9",width=2,background='green',name="hour_9")
hour_9.grid(row=2,column=9)
hour_9.bind("<Double-Button-1>",lambda event:displayschinfo(event,9))
hour_10 = tk.Label(schframe,text="10",width=2,background='green',name="hour_10")
hour_10.grid(row=2,column=10)
hour_10.bind("<Double-Button-1>",lambda event:displayschinfo(event,10))
hour_11 = tk.Label(schframe,text="11",width=2,background='green',name="hour_11")
hour_11.grid(row=2,column=11)
hour_11.bind("<Double-Button-1>",lambda event:displayschinfo(event,11))
hour_12 = tk.Label(schframe,text="12",width=2,background='green',name="hour_12")
hour_12.grid(row=2,column=12)
hour_12.bind("<Double-Button-1>",lambda event:displayschinfo(event,12))
hour_13 = tk.Label(schframe,text="13",width=2,background='green',name="hour_13")
hour_13.grid(row=2,column=13)
hour_13.bind("<Double-Button-1>",lambda event:displayschinfo(event,13))
hour_14 = tk.Label(schframe,text="14",width=2,background='green',name="hour_14")
hour_14.grid(row=2,column=14)
hour_14.bind("<Double-Button-1>",lambda event:displayschinfo(event,14))
hour_15 = tk.Label(schframe,text="15",width=2,background='green',name="hour_15")
hour_15.grid(row=2,column=15)
hour_15.bind("<Double-Button-1>",lambda event:displayschinfo(event,15))
hour_16 = tk.Label(schframe,text="16",width=2,background='green',name="hour_16")
hour_16.grid(row=2,column=16)
hour_16.bind("<Double-Button-1>",lambda event:displayschinfo(event,16))
hour_17 = tk.Label(schframe,text="17",width=2,background='green',name="hour_17")
hour_17.grid(row=2,column=17)
hour_17.bind("<Double-Button-1>",lambda event:displayschinfo(event,17))
hour_18 = tk.Label(schframe,text="18",width=2,background='green',name="hour_18")
hour_18.grid(row=2,column=18)
hour_18.bind("<Double-Button-1>",lambda event:displayschinfo(event,18))
hour_19 = tk.Label(schframe,text="19",width=2,background='green',name="hour_19")
hour_19.grid(row=2,column=19)
hour_19.bind("<Double-Button-1>",lambda event:displayschinfo(event,19))
hour_20 = tk.Label(schframe,text="20",width=2,background='green',name="hour_20")
hour_20.grid(row=2,column=20)
hour_20.bind("<Double-Button-1>",lambda event:displayschinfo(event,20))
hour_21 = tk.Label(schframe,text="21",width=2,background='green',name="hour_21")
hour_21.grid(row=2,column=21)
hour_21.bind("<Double-Button-1>",lambda event:displayschinfo(event,21))
hour_22 = tk.Label(schframe,text="22",width=2,background='green',name="hour_22")
hour_22.grid(row=2,column=22)
hour_22.bind("<Double-Button-1>",lambda event:displayschinfo(event,22))
hour_23 = tk.Label(schframe,text="23",width=2,background='green',name="hour_23")
hour_23.grid(row=2,column=23)
hour_23.bind("<Double-Button-1>",lambda event:displayschinfo(event,23))
#Get the current date and enter it by default into the schedule navigator.
initialdate = datetime.date.today()
inityr = tk.StringVar(schframe,value=str(initialdate.year))
initdy = tk.StringVar(schframe,value=str(initialdate.day))
initmo = tk.StringVar(schframe,value=str(initialdate.month))
dy_ent =tk.Entry(schframe,textvariable=initdy,width=4,justify=tk.CENTER)
dy_ent.grid(row=0,column = 8,columnspan=2)
dy_ent.bind('<Return>',lambda event:confirmdate.invoke())
mo_ent =tk.Entry(schframe,textvariable=initmo,width=4,justify=tk.CENTER)
mo_ent.grid(row=0,column = 11,columnspan=2)
mo_ent.bind('<Return>',lambda event:confirmdate.invoke())
yr_ent =tk.Entry(schframe,textvariable=inityr,width=4,justify=tk.CENTER)
yr_ent.grid(row=0,column = 14,columnspan=2)
yr_ent.bind('<Return>',lambda event:confirmdate.invoke())
dylab = tk.Label(schframe,text='-',width=2)
dylab.grid(row=0,column=10)
molab = tk.Label(schframe,text='-',width=2)
molab.grid(row=0,column=13)
#More widgets! These are for schedule information entry.
confirmdate = tk.Button(schframe,text="Go",
command=lambda: enterdate(dy_ent.get(),mo_ent.get(),yr_ent.get()),width=1)
confirmdate.grid(row=0,column=20,columnspan=2)
sthr_ent = tk.Entry(schframe,width=4,justify=tk.CENTER)
sthr_ent.grid(row=4,column=6,columnspan=2)
sthr_lab = tk.Label(schframe,width=11,text="Start Hour:")
sthr_lab.grid(row=4,column=0,columnspan=5,sticky=tk.N+tk.E+tk.S+tk.W)
fnhr_ent = tk.Entry(schframe,width=4,justify=tk.CENTER)
fnhr_ent.grid(row=5,column=6,columnspan=2,sticky=tk.N+tk.E+tk.S+tk.W)
fnhr_lab = tk.Label(schframe,width=11,text = "End Hour:")
fnhr_lab.grid(row=5,column=0,columnspan=5)
obj_ent = ttk.Combobox(schframe, values=["Sun", "Moon", "Cassiopeia A", "Sagittarius A", "Cygnus A",
"Crab Nebula"], state="readonly", width=12)
obj_ent.grid(row=6,column=4,columnspan=6,sticky=tk.N+tk.E+tk.S+tk.W)
obj_lab = tk.Label(schframe, width = 8,text="Object:")
obj_lab.grid(row=6,column=0,columnspan = 4,sticky=tk.N+tk.E+tk.S+tk.W)
author_ent = tk.Entry(schframe,width=12)
author_ent.grid(row=7,column=4,columnspan=6,sticky=tk.N+tk.E+tk.S+tk.W)
author_lab = tk.Label(schframe,width=8,text = "Author:")
author_lab.grid(row=7,column=0,columnspan=4,sticky=tk.N+tk.E+tk.S+tk.W)
note_ent = tk.Text(schframe,width = 24,height=4)
note_ent.grid(row=5,column=11,columnspan=12,rowspan = 4,sticky=tk.N+tk.E+tk.S+tk.W)
note_lab = tk.Label(schframe,width=20,text = "Schedule Note w/ email:")
note_lab.grid(row=4,column=11,columnspan=10,sticky=tk.N+tk.E+tk.S+tk.W)
track_check = tk.BooleanVar()
track_checkbox = tk.Checkbutton(schframe,variable=track_check)
track_checkbox.grid(row=8,column=4,columnspan=2)
track_lab = tk.Label(schframe,width=8,text= "Track?:")
track_lab.grid(row=8,column=0,columnspan=4,sticky=tk.N+tk.E+tk.S+tk.W)
chop_check = tk.BooleanVar()
chop_checkbox = tk.Checkbutton(schframe,variable=chop_check)
chop_checkbox.grid(row=9,column=4,columnspan=2)
chop_lab = tk.Label(schframe,width=8,text = "Chop?:")
chop_lab.grid(row=9,column=0,columnspan=4,sticky=tk.N+tk.E+tk.S+tk.W)
save_schedulebutton = tk.Button(schframe,text="Save Schedule",
command=lambda:saveobsslot(dy_ent.get(),mo_ent.get(),yr_ent.get(),
sthr_ent.get(),fnhr_ent.get(),obj_ent.get(),
author_ent.get(),note_ent.get("1.0",'end-1c'),