-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathEDAPGui.py
More file actions
1510 lines (1263 loc) · 80.3 KB
/
EDAPGui.py
File metadata and controls
1510 lines (1263 loc) · 80.3 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
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
# import queue
# import sys
# import os
# import threading
# import kthread
# from datetime import datetime
# from time import sleep
# import cv2
# import json
# from pathlib import Path
import subprocess
import keyboard
import webbrowser
# import requests
# from PIL import Image, ImageGrab, ImageTk
import tkinter as tk
from tkinter import filedialog as fd
# from tkinter import messagebox
from tkinter import ttk
import sv_ttk
import pywinstyles
import sys # Do not delete - prevents a 'super' error from tktoolip.
from tktooltip import ToolTip # In requirements.txt as 'tkinter-tooltip'.
# from OCR import RegionCalibration
# from Voice import *
# from MousePt import MousePoint
# from Image_Templates import *
# from Screen import *
# from Screen_Regions import *
# from EDKeys import *
# from EDJournal import *
from ED_AP import *
from EDAPWaypointEditor import WaypointEditorTab
from EDlogger import logger
"""
File:EDAPGui.py
Description:
User interface for controlling the ED Autopilot
Note:
Ideas taken from: https://github.com/skai2/EDAutopilot
HotKeys:
Home - Start FSD Assist
INS - Start SC Assist
PG UP - Start Robigo Assist
End - Terminate any ongoing assist (FSD, SC, AFK)
Author: sumzer0@yahoo.com
"""
# ---------------------------------------------------------------------------
# must be updated with a new release so that the update check works properly!
# contains the names of the release.
EDAP_VERSION = "V1.8.0"
# depending on how release versions are best marked you could also change it to the release tag, see function check_update.
# ---------------------------------------------------------------------------
FORM_TYPE_CHECKBOX = 0
FORM_TYPE_SPINBOX = 1
FORM_TYPE_ENTRY = 2
def str_to_float(input_str: str) -> float:
try:
return float(input_str)
except ValueError:
return 0.0 # Assign a default value on error
class APGui:
def __init__(self, root):
self.statusbar = None
self.root = root
root.title("EDAutopilot " + EDAP_VERSION)
# root.overrideredirect(True)
# root.geometry("400x550")
# root.configure(bg="blue")
root.protocol("WM_DELETE_WINDOW", self.close_window)
root.resizable(False, False)
self.tooltips = {
'FSD Route Assist': "Will execute your route. \nAt each jump the sequence will perform some fuel scooping.",
'Supercruise Assist': "Will keep your ship pointed to target, \nyou target can only be a station for the autodocking to work.",
'Waypoint Assist': "When selected, will prompt for the waypoint file. \nThe waypoint file contains System names that \nwill be entered into Galaxy Map and route plotted.",
'Robigo Assist': "",
'DSS Assist': "When selected, will perform DSS scans while you are traveling between stars.",
'Single Waypoint Assist': "",
'ELW Scanner': "Will perform FSS scans while FSD Assist is traveling between stars. \nIf the FSS shows a signal in the region of Earth, \nWater or Ammonia type worlds, it will announce that discovery.",
'AFK Combat Assist': "Used with a AFK Combat ship in a Rez Zone.",
'RollRate': "Roll rate your ship has in deg/sec. Higher the number the more maneuverable the ship.",
'PitchRate': "Pitch (up/down) rate your ship has in deg/sec. Higher the number the more maneuverable the ship.",
'YawRate': "Yaw rate (rudder) your ship has in deg/sec. Higher the number the more maneuverable the ship.",
'RollFactor': "TBD",
'PitchFactor': "TBD",
'YawFactor': "TBD",
'SunPitchUp+Time': "This field are for ship that tend to overheat. \nProviding 1-2 more seconds of Pitch up when avoiding the Sun \nwill overcome this problem.",
'Sun Bright Threshold': "The low level for brightness detection, \nrange 0-255, want to mask out darker items",
'Nav Align Tries': "How many attempts the ap should make at alignment.",
'Jump Tries': "How many attempts the ap should make to jump.",
'Docking Retries': "How many attempts to make to dock.",
'Wait For Autodock': "After docking granted, \nwait this amount of time for us to get docked with autodocking",
'Start FSD': "Button to start FSD route assist.",
'Start SC': "Button to start Supercruise assist.",
'Start Robigo': "Button to start Robigo assist.",
'Stop All': "Button to stop all assists.",
'Refuel Threshold': "If fuel level get below this level, \nit will attempt refuel.",
'Scoop Timeout': "Number of second to wait for full tank, \nmight mean we are not scooping well or got a small scooper",
'Fuel Threshold Abort': "Level at which AP will terminate, \nbecause we are not scooping well.",
'X Offset': "Offset left the screen to start place overlay text.",
'Y Offset': "Offset down the screen to start place overlay text.",
'Font Size': "Font size of the overlay.",
'Calibrate': "Will iterate through a set of scaling values \ngetting the best match for your system. \nSee HOWTO-Calibrate.md",
'Waypoint List Button': "Read in a file with with your Waypoints.",
'Cap Mouse XY': "This will provide the StationCoord value of the Station in the SystemMap. \nSelecting this button and then clicking on the Station in the SystemMap \nwill return the x,y value that can be pasted in the waypoints file",
'Reset Waypoint List': "Reset your waypoint list, \nthe waypoint assist will start again at the first point in the list.",
'Debug Overlay': "Enables debug data to be displayed over the \nElite Dangerous screen while playing the game.",
'Debug OCR': "Enables OCR debug output to be stored in the 'ocr_output' folder.",
'Debug Images': "Enables debug images to be stored in the 'debug_output' folder.",
'Modifier Key Delay': "Delay for key modifiers to ensure modifier is detected before/after the key.",
'Default Hold Time': "Default hold time for a key press.",
'Repeat Key Delay': "Delay between key press repeats.",
}
self.gui_loaded = False
self.log_buffer = queue.Queue()
self.callback('log', f'Starting ED Autopilot {EDAP_VERSION}.')
self.load_ocr_calibration_data()
self.ed_ap = EDAutopilot(cb=self.callback)
self.ed_ap.robigo.set_single_loop(self.ed_ap.config['Robigo_Single_Loop'])
# self.calibrator = RegionCalibration(root, self.ed_ap, cb=self.callback)
self.ocr_calibration_data = {}
self.mouse = MousePoint()
self.checkboxvar = {}
self.radiobuttonvar = {}
self.entries = {}
self.lab_ck = {}
self.single_waypoint_system = tk.StringVar()
self.single_waypoint_station = tk.StringVar()
self._global_shopping_list_tab = None
self.waypoint_editor_tab = None
self.FSD_A_running = False
self.SC_A_running = False
self.WP_A_running = False
self.RO_A_running = False
self.DSS_A_running = False
self.SWP_A_running = False
self.cv_view = False
self.msgList = self.gui_gen(root)
self.checkboxvar['Enable Randomness'].set(self.ed_ap.config['EnableRandomness'])
self.checkboxvar['Activate Elite for each key'].set(self.ed_ap.config['ActivateEliteEachKey'])
self.checkboxvar['Automatic logout'].set(self.ed_ap.config['AutomaticLogout'])
self.checkboxvar['Enable Overlay'].set(self.ed_ap.config['OverlayTextEnable'])
self.checkboxvar['Enable Voice'].set(self.ed_ap.config['VoiceEnable'])
self.checkboxvar['Enable Hotkeys'].set(self.ed_ap.config['HotkeysEnable'])
self.checkboxvar['Debug Overlay'].set(self.ed_ap.config['DebugOverlay'])
self.checkboxvar['Debug OCR'].set(self.ed_ap.config['DebugOCR'])
self.checkboxvar['Debug Images'].set(self.ed_ap.config['DebugImages'])
self.checkboxvar['AFKCombat AttackAtWill'].set(self.ed_ap.config['AFKCombat_AttackAtWill'])
self.radiobuttonvar['dss_button'].set(self.ed_ap.config['DSSButton'])
self.entries['ship']['PitchRate'].delete(0, tk.END)
self.entries['ship']['RollRate'].delete(0, tk.END)
self.entries['ship']['YawRate'].delete(0, tk.END)
self.entries['ship']['SunPitchUp+Time'].delete(0, tk.END)
self.entries['ship']['PitchFactor'].delete(0, tk.END)
self.entries['ship']['RollFactor'].delete(0, tk.END)
self.entries['ship']['YawFactor'].delete(0, tk.END)
self.entries['autopilot']['Sun Bright Threshold'].delete(0, tk.END)
self.entries['autopilot']['Nav Align Tries'].delete(0, tk.END)
self.entries['autopilot']['Jump Tries'].delete(0, tk.END)
self.entries['autopilot']['Docking Retries'].delete(0, tk.END)
self.entries['autopilot']['Wait For Autodock'].delete(0, tk.END)
self.entries['refuel']['Refuel Threshold'].delete(0, tk.END)
self.entries['refuel']['Scoop Timeout'].delete(0, tk.END)
self.entries['refuel']['Fuel Threshold Abort'].delete(0, tk.END)
self.entries['overlay']['X Offset'].delete(0, tk.END)
self.entries['overlay']['Y Offset'].delete(0, tk.END)
self.entries['overlay']['Font Size'].delete(0, tk.END)
self.entries['buttons']['Start FSD'].delete(0, tk.END)
self.entries['buttons']['Start SC'].delete(0, tk.END)
self.entries['buttons']['Start Robigo'].delete(0, tk.END)
self.entries['buttons']['Stop All'].delete(0, tk.END)
self.entries['keys']['Modifier Key Delay'].delete(0, tk.END)
self.entries['keys']['Default Hold Time'].delete(0, tk.END)
self.entries['keys']['Repeat Key Delay'].delete(0, tk.END)
self.entries['ship']['PitchRate'].insert(0, float(self.ed_ap.pitchrate))
self.entries['ship']['RollRate'].insert(0, float(self.ed_ap.rollrate))
self.entries['ship']['YawRate'].insert(0, float(self.ed_ap.yawrate))
self.entries['ship']['SunPitchUp+Time'].insert(0, float(self.ed_ap.sunpitchuptime))
self.entries['ship']['PitchFactor'].insert(0, float(self.ed_ap.pitchfactor))
self.entries['ship']['RollFactor'].insert(0, float(self.ed_ap.rollfactor))
self.entries['ship']['YawFactor'].insert(0, float(self.ed_ap.yawfactor))
self.entries['autopilot']['Sun Bright Threshold'].insert(0, int(self.ed_ap.config['SunBrightThreshold']))
self.entries['autopilot']['Nav Align Tries'].insert(0, int(self.ed_ap.config['NavAlignTries']))
self.entries['autopilot']['Jump Tries'].insert(0, int(self.ed_ap.config['JumpTries']))
self.entries['autopilot']['Docking Retries'].insert(0, int(self.ed_ap.config['DockingRetries']))
self.entries['autopilot']['Wait For Autodock'].insert(0, int(self.ed_ap.config['WaitForAutoDockTimer']))
self.entries['refuel']['Refuel Threshold'].insert(0, int(self.ed_ap.config['RefuelThreshold']))
self.entries['refuel']['Scoop Timeout'].insert(0, int(self.ed_ap.config['FuelScoopTimeOut']))
self.entries['refuel']['Fuel Threshold Abort'].insert(0, int(self.ed_ap.config['FuelThreasholdAbortAP']))
self.entries['overlay']['X Offset'].insert(0, int(self.ed_ap.config['OverlayTextXOffset']))
self.entries['overlay']['Y Offset'].insert(0, int(self.ed_ap.config['OverlayTextYOffset']))
self.entries['overlay']['Font Size'].insert(0, int(self.ed_ap.config['OverlayTextFontSize']))
self.entries['buttons']['Start FSD'].insert(0, str(self.ed_ap.config['HotKey_StartFSD']))
self.entries['buttons']['Start SC'].insert(0, str(self.ed_ap.config['HotKey_StartSC']))
self.entries['buttons']['Start Robigo'].insert(0, str(self.ed_ap.config['HotKey_StartRobigo']))
self.entries['buttons']['Stop All'].insert(0, str(self.ed_ap.config['HotKey_StopAllAssists']))
self.entries['keys']['Modifier Key Delay'].insert(0, float(self.ed_ap.config['Key_ModDelay']))
self.entries['keys']['Default Hold Time'].insert(0, float(self.ed_ap.config['Key_DefHoldTime']))
self.entries['keys']['Repeat Key Delay'].insert(0, float(self.ed_ap.config['Key_RepeatDelay']))
if self.ed_ap.config['LogDEBUG']:
self.radiobuttonvar['debug_mode'].set("Debug")
elif self.ed_ap.config['LogINFO']:
self.radiobuttonvar['debug_mode'].set("Info")
else:
self.radiobuttonvar['debug_mode'].set("Error")
# global trap for these keys, the 'end' key will stop any current AP action
# the 'home' key will start the FSD Assist. May want another to start SC Assist
if self.ed_ap.config['HotkeysEnable']:
keyboard.add_hotkey(self.ed_ap.config['HotKey_StopAllAssists'], self.stop_all_assists)
keyboard.add_hotkey(self.ed_ap.config['HotKey_StartFSD'], self.callback, args=('fsd_start', None))
keyboard.add_hotkey(self.ed_ap.config['HotKey_StartSC'], self.callback, args=('sc_start', None))
keyboard.add_hotkey(self.ed_ap.config['HotKey_StartRobigo'], self.callback, args=('robigo_start', None))
# check for updates
self.check_updates()
sleep(0.25) # Added because the custom tkinter takes longer to load? Without, you occasionally get errors
# that the main thread is not in main loop.
self.ed_ap.gui_loaded = True
self.gui_loaded = True
# Send a log entry which will flush out the buffer.
self.callback('log', 'ED Autopilot loaded successfully.')
# callback from the EDAP, to configure GUI items
def callback(self, msg, body=None):
if msg == 'log':
self.log_msg(body)
elif msg == 'log+vce':
self.log_msg(body)
self.ed_ap.vce.say(body)
elif msg == 'statusline':
self.update_statusline(body)
elif msg == 'fsd_stop':
logger.debug("Detected 'fsd_stop' callback msg")
self.checkboxvar['FSD Route Assist'].set(0)
self.check_cb('FSD Route Assist')
elif msg == 'fsd_start':
self.checkboxvar['FSD Route Assist'].set(1)
self.check_cb('FSD Route Assist')
elif msg == 'sc_stop':
logger.debug("Detected 'sc_stop' callback msg")
self.checkboxvar['Supercruise Assist'].set(0)
self.check_cb('Supercruise Assist')
elif msg == 'sc_start':
self.checkboxvar['Supercruise Assist'].set(1)
self.check_cb('Supercruise Assist')
elif msg == 'waypoint_stop':
logger.debug("Detected 'waypoint_stop' callback msg")
self.checkboxvar['Waypoint Assist'].set(0)
self.check_cb('Waypoint Assist')
elif msg == 'waypoint_start':
self.checkboxvar['Waypoint Assist'].set(1)
self.check_cb('Waypoint Assist')
elif msg == 'robigo_stop':
logger.debug("Detected 'robigo_stop' callback msg")
self.checkboxvar['Robigo Assist'].set(0)
self.check_cb('Robigo Assist')
elif msg == 'robigo_start':
self.checkboxvar['Robigo Assist'].set(1)
self.check_cb('Robigo Assist')
elif msg == 'afk_stop':
logger.debug("Detected 'afk_stop' callback msg")
self.checkboxvar['AFK Combat Assist'].set(0)
self.check_cb('AFK Combat Assist')
elif msg == 'dss_start':
logger.debug("Detected 'dss_start' callback msg")
self.checkboxvar['DSS Assist'].set(1)
self.check_cb('DSS Assist')
elif msg == 'dss_stop':
logger.debug("Detected 'dss_stop' callback msg")
self.checkboxvar['DSS Assist'].set(0)
self.check_cb('DSS Assist')
elif msg == 'single_waypoint_stop':
logger.debug("Detected 'single_waypoint_stop' callback msg")
self.checkboxvar['Single Waypoint Assist'].set(0)
self.check_cb('Single Waypoint Assist')
elif msg == 'stop_all_assists':
logger.debug("Detected 'stop_all_assists' callback msg")
self.checkboxvar['FSD Route Assist'].set(0)
self.check_cb('FSD Route Assist')
self.checkboxvar['Supercruise Assist'].set(0)
self.check_cb('Supercruise Assist')
self.checkboxvar['Waypoint Assist'].set(0)
self.check_cb('Waypoint Assist')
self.checkboxvar['Robigo Assist'].set(0)
self.check_cb('Robigo Assist')
self.checkboxvar['AFK Combat Assist'].set(0)
self.check_cb('AFK Combat Assist')
self.checkboxvar['DSS Assist'].set(0)
self.check_cb('DSS Assist')
self.checkboxvar['Single Waypoint Assist'].set(0)
self.check_cb('Single Waypoint Assist')
elif msg == 'jumpcount':
self.update_jumpcount(body)
elif msg == 'update_ship_cfg':
self.update_ship_cfg()
def update_ship_cfg(self):
# load up the display with what we read from ED_AP for the current ship
self.entries['ship']['PitchRate'].delete(0, tk.END)
self.entries['ship']['RollRate'].delete(0, tk.END)
self.entries['ship']['YawRate'].delete(0, tk.END)
self.entries['ship']['SunPitchUp+Time'].delete(0, tk.END)
self.entries['ship']['PitchFactor'].delete(0, tk.END)
self.entries['ship']['RollFactor'].delete(0, tk.END)
self.entries['ship']['YawFactor'].delete(0, tk.END)
self.entries['ship']['PitchRate'].insert(0, self.ed_ap.pitchrate)
self.entries['ship']['RollRate'].insert(0, self.ed_ap.rollrate)
self.entries['ship']['YawRate'].insert(0, self.ed_ap.yawrate)
self.entries['ship']['SunPitchUp+Time'].insert(0, self.ed_ap.sunpitchuptime)
self.entries['ship']['PitchFactor'].insert(0, self.ed_ap.pitchfactor)
self.entries['ship']['RollFactor'].insert(0, self.ed_ap.rollfactor)
self.entries['ship']['YawFactor'].insert(0, self.ed_ap.yawfactor)
def calibrate_callback(self):
self.ed_ap.calibrate_target()
def calibrate_compass_callback(self):
self.ed_ap.calibrate_compass()
def quit(self):
logger.debug("Entered: quit")
self.close_window()
def close_window(self):
logger.debug("Entered: close_window")
self.stop_fsd()
self.stop_sc()
self.ed_ap.quit()
sleep(0.1)
self.root.destroy()
# this routine is to stop any current autopilot activity
def stop_all_assists(self):
logger.debug("Entered: stop_all_assists")
self.callback('stop_all_assists')
def start_fsd(self):
logger.debug("Entered: start_fsd")
self.ed_ap.set_fsd_assist(True)
self.FSD_A_running = True
self.log_msg("FSD Route Assist start")
self.ed_ap.vce.say("FSD Route Assist On")
def stop_fsd(self):
logger.debug("Entered: stop_fsd")
self.ed_ap.set_fsd_assist(False)
self.FSD_A_running = False
self.log_msg("FSD Route Assist stop")
self.ed_ap.vce.say("FSD Route Assist Off")
self.update_statusline("Idle")
def start_sc(self):
logger.debug("Entered: start_sc")
self.ed_ap.set_sc_assist(True)
self.SC_A_running = True
self.log_msg("SC Assist start")
self.ed_ap.vce.say("Supercruise Assist On")
def stop_sc(self):
logger.debug("Entered: stop_sc")
self.ed_ap.set_sc_assist(False)
self.SC_A_running = False
self.log_msg("SC Assist stop")
self.ed_ap.vce.say("Supercruise Assist Off")
self.update_statusline("Idle")
def start_waypoint(self):
logger.debug("Entered: start_waypoint")
self.ed_ap.set_waypoint_assist(True)
self.WP_A_running = True
self.log_msg("Waypoint Assist start")
self.ed_ap.vce.say("Waypoint Assist On")
def stop_waypoint(self):
logger.debug("Entered: stop_waypoint")
self.ed_ap.set_waypoint_assist(False)
self.WP_A_running = False
self.log_msg("Waypoint Assist stop")
self.ed_ap.vce.say("Waypoint Assist Off")
self.update_statusline("Idle")
def start_robigo(self):
logger.debug("Entered: start_robigo")
self.ed_ap.set_robigo_assist(True)
self.RO_A_running = True
self.log_msg("Robigo Assist start")
self.ed_ap.vce.say("Robigo Assist On")
def stop_robigo(self):
logger.debug("Entered: stop_robigo")
self.ed_ap.set_robigo_assist(False)
self.RO_A_running = False
self.log_msg("Robigo Assist stop")
self.ed_ap.vce.say("Robigo Assist Off")
self.update_statusline("Idle")
def start_dss(self):
logger.debug("Entered: start_dss")
self.ed_ap.set_dss_assist(True)
self.DSS_A_running = True
self.log_msg("DSS Assist start")
self.ed_ap.vce.say("DSS Assist On")
def stop_dss(self):
logger.debug("Entered: stop_dss")
self.ed_ap.set_dss_assist(False)
self.DSS_A_running = False
self.log_msg("DSS Assist stop")
self.ed_ap.vce.say("DSS Assist Off")
self.update_statusline("Idle")
def start_single_waypoint_assist(self):
""" The debug command to go to a system or station or both."""
logger.debug("Entered: start_single_waypoint_assist")
system = self.single_waypoint_system.get()
station = self.single_waypoint_station.get()
if system != "" or station != "":
self.ed_ap.set_single_waypoint_assist(system, station, True)
self.SWP_A_running = True
self.log_msg("Single Waypoint Assist start")
self.ed_ap.vce.say("Single Waypoint Assist On")
def stop_single_waypoint_assist(self):
""" The debug command to go to a system or station or both."""
logger.debug("Entered: stop_single_waypoint_assist")
self.ed_ap.set_single_waypoint_assist("", "", False)
self.SWP_A_running = False
self.log_msg("Single Waypoint Assist stop")
self.ed_ap.vce.say("Single Waypoint Assist Off")
self.update_statusline("Idle")
def about(self):
webbrowser.open_new("https://github.com/SumZer0-git/EDAPGui")
def check_for_updates(self, repo_path):
try:
# Fetch the latest changes from the remote repository
subprocess.run(["git", "fetch"], cwd=repo_path, check=True, capture_output=True)
# Get the current commit hash of the local repository
local_hash = subprocess.run(["git", "rev-parse", "HEAD"], cwd=repo_path, capture_output=True, text=True,
check=True).stdout.strip()
# Get the commit hash of the remote repository
remote_hash = subprocess.run(["git", "rev-parse", "origin/HEAD"], cwd=repo_path, capture_output=True,
text=True, check=True).stdout.strip()
# Compare the commit hashes
if local_hash != remote_hash:
print("The repository has been updated. Please clone it again to get the latest version.")
return True
else:
print("The repository is up to date.")
return False
except subprocess.CalledProcessError as e:
print(f"Error checking for updates: {e}")
return False
except FileNotFoundError:
print("Git command not found. Please ensure Git is installed and in your system's PATH.")
return False
def check_updates(self):
# response = requests.get("https://api.github.com/repos/SumZer0-git/EDAPGui/releases/latest")
# if EDAP_VERSION != response.json()["name"]:
# mb = messagebox.askokcancel("Update Check", "A new release version is available. Download now?")
# if mb == True:
# webbrowser.open_new("https://github.com/SumZer0-git/EDAPGui/releases/latest")
# Example usage:
# repo_path = "/path/to/your/local/repo"
repo_path = "./"
updates_available = self.check_for_updates(repo_path)
if updates_available:
# Optionally, provide further instructions or automate the cloning process
self.log_msg("=====================================================")
self.log_msg("========== An update to EDAP is available ===========")
self.log_msg("==== Click 'Check for Updates' on the Debug tab, ====")
self.log_msg("====== or go directly to the EDAP Github page =======")
self.log_msg("=====================================================")
# print("You can use the following command to clone the repository again:")
# print("git clone <repository_url> <new_directory_name>")
else:
self.log_msg("You have the latest version of EDAP!")
def open_changelog(self):
webbrowser.open_new("https://github.com/SumZer0-git/EDAPGui/blob/main/ChangeLog.md")
def open_discord(self):
webbrowser.open_new("https://discord.gg/HCgkfSc")
def open_logfile(self):
os.startfile('autopilot.log')
def log_msg(self, msg):
message = datetime.now().strftime("%H:%M:%S: ") + msg
try:
if not self.gui_loaded:
# Store message in queue
self.log_buffer.put(message)
logger.info(msg)
else:
# Add queued messages to the list
while not self.log_buffer.empty():
self.msgList.insert(tk.END, self.log_buffer.get())
self.msgList.insert(tk.END, message)
self.msgList.yview(tk.END)
logger.info(msg)
except:
# Store message in queue
self.log_buffer.put(message)
logger.info(msg)
def set_statusbar(self, txt):
self.statusbar.configure(text=txt)
def update_jumpcount(self, txt):
self.jumpcount.configure(text=txt)
def update_statusline(self, txt):
self.status.configure(text="Status: " + txt)
self.log_msg(f"Status update: {txt}")
def ship_tst_pitch(self):
# self.ed_ap.ship_tst_pitch(360)
# self.ed_ap.ship_tst_pitch_new(360)
self.ed_ap.ship_tst_pitch_enabled = True
def ship_tst_roll(self):
# self.ed_ap.ship_tst_roll(360)
# self.ed_ap.ship_tst_roll_new(360)
self.ed_ap.ship_tst_roll_enabled = True
def ship_tst_yaw(self):
# self.ed_ap.ship_tst_yaw(360)
# self.ed_ap.ship_tst_yaw_new(360)
self.ed_ap.ship_tst_yaw_enabled = True
def ship_tst_pitch_30(self):
self.ed_ap.ship_tst_pitch(30)
def ship_tst_roll_30(self):
self.ed_ap.ship_tst_roll(30)
def ship_tst_yaw_30(self):
self.ed_ap.ship_tst_yaw(30)
def ship_tst_pitch_45(self):
self.ed_ap.ship_tst_pitch(45)
def ship_tst_roll_45(self):
self.ed_ap.ship_tst_roll(45)
def ship_tst_yaw_45(self):
self.ed_ap.ship_tst_yaw(45)
def ship_tst_pitch_90(self):
self.ed_ap.ship_tst_pitch(90)
def ship_tst_roll_90(self):
self.ed_ap.ship_tst_roll(90)
def ship_tst_yaw_90(self):
self.ed_ap.ship_tst_yaw(90)
def open_wp_file(self):
filetypes = (
('json files', '*.json'),
('All files', '*.*')
)
filename = fd.askopenfilename(title="Waypoint File", initialdir='./waypoints/', filetypes=filetypes)
if filename != "":
res = self.ed_ap.waypoint.load_waypoint_file(filename)
if res:
self.wp_filelabel.set("loaded: " + Path(filename).name)
else:
self.wp_filelabel.set("<no list loaded>")
def reset_wp_file(self):
if not self.WP_A_running:
mb = messagebox.askokcancel("Waypoint List Reset", "After resetting the Waypoint List, the Waypoint Assist will start again from the first point in the list at the next start.")
if mb:
self.ed_ap.waypoint.mark_all_waypoints_not_complete()
else:
mb = messagebox.showerror("Waypoint List Error", "Waypoint Assist must be disabled before you can reset the list.")
def save_settings(self):
self.entry_update(None)
self.ed_ap.update_config()
self.ed_ap.update_ship_configs()
self.save_ocr_calibration_data()
self.log_msg("Saved all settings.")
# new data was added to a field, re-read them all for simple logic
def entry_update(self, event):
try:
self.ed_ap.pitchrate = float(self.entries['ship']['PitchRate'].get())
self.ed_ap.rollrate = float(self.entries['ship']['RollRate'].get())
self.ed_ap.yawrate = float(self.entries['ship']['YawRate'].get())
self.ed_ap.sunpitchuptime = float(self.entries['ship']['SunPitchUp+Time'].get())
self.ed_ap.pitchfactor = float(self.entries['ship']['PitchFactor'].get())
self.ed_ap.rollfactor = float(self.entries['ship']['RollFactor'].get())
self.ed_ap.yawfactor = float(self.entries['ship']['YawFactor'].get())
self.ed_ap.config['SunBrightThreshold'] = int(self.entries['autopilot']['Sun Bright Threshold'].get())
self.ed_ap.config['NavAlignTries'] = int(self.entries['autopilot']['Nav Align Tries'].get())
self.ed_ap.config['JumpTries'] = int(self.entries['autopilot']['Jump Tries'].get())
self.ed_ap.config['DockingRetries'] = int(self.entries['autopilot']['Docking Retries'].get())
self.ed_ap.config['WaitForAutoDockTimer'] = int(self.entries['autopilot']['Wait For Autodock'].get())
self.ed_ap.config['RefuelThreshold'] = int(self.entries['refuel']['Refuel Threshold'].get())
self.ed_ap.config['FuelScoopTimeOut'] = int(self.entries['refuel']['Scoop Timeout'].get())
self.ed_ap.config['FuelThreasholdAbortAP'] = int(self.entries['refuel']['Fuel Threshold Abort'].get())
self.ed_ap.config['OverlayTextXOffset'] = int(self.entries['overlay']['X Offset'].get())
self.ed_ap.config['OverlayTextYOffset'] = int(self.entries['overlay']['Y Offset'].get())
self.ed_ap.config['OverlayTextFontSize'] = int(self.entries['overlay']['Font Size'].get())
self.ed_ap.config['HotKey_StartFSD'] = str(self.entries['buttons']['Start FSD'].get())
self.ed_ap.config['HotKey_StartSC'] = str(self.entries['buttons']['Start SC'].get())
self.ed_ap.config['HotKey_StartRobigo'] = str(self.entries['buttons']['Start Robigo'].get())
self.ed_ap.config['HotKey_StopAllAssists'] = str(self.entries['buttons']['Stop All'].get())
self.ed_ap.config['VoiceEnable'] = self.checkboxvar['Enable Voice'].get()
self.ed_ap.config['DebugOverlay'] = self.checkboxvar['Debug Overlay'].get()
self.ed_ap.config['AFKCombat_AttackAtWill'] = self.checkboxvar['AFKCombat AttackAtWill'].get()
self.ed_ap.config['HotkeysEnable'] = self.checkboxvar['Enable Hotkeys'].get()
self.ed_ap.config['DebugOCR'] = self.checkboxvar['Debug OCR'].get()
self.ed_ap.config['DebugImages'] = self.checkboxvar['Debug Images'].get()
self.ed_ap.config['Key_ModDelay'] = float(self.entries['keys']['Modifier Key Delay'].get())
self.ed_ap.config['Key_DefHoldTime'] = float(self.entries['keys']['Default Hold Time'].get())
self.ed_ap.config['Key_RepeatDelay'] = float(self.entries['keys']['Repeat Key Delay'].get())
# Process config[] settings to update classes as necessary
self.ed_ap.process_config_settings()
except:
messagebox.showinfo("Exception", "Invalid float entered")
# ckbox.state:(ACTIVE | DISABLED)
# ('FSD Route Assist', 'Supercruise Assist', 'Enable Voice', 'Enable CV View')
def check_cb(self, field):
# print("got event:", checkboxvar['FSD Route Assist'].get(), " ", str(FSD_A_running))
if field == 'FSD Route Assist':
if self.checkboxvar['FSD Route Assist'].get() == 1 and self.FSD_A_running == False:
self.lab_ck['AFK Combat Assist'].config(state='disabled')
self.lab_ck['Supercruise Assist'].config(state='disabled')
self.lab_ck['Waypoint Assist'].config(state='disabled')
self.lab_ck['Robigo Assist'].config(state='disabled')
self.lab_ck['DSS Assist'].config(state='disabled')
self.start_fsd()
elif self.checkboxvar['FSD Route Assist'].get() == 0 and self.FSD_A_running == True:
self.stop_fsd()
self.lab_ck['Supercruise Assist'].config(state='active')
self.lab_ck['AFK Combat Assist'].config(state='active')
self.lab_ck['Waypoint Assist'].config(state='active')
self.lab_ck['Robigo Assist'].config(state='active')
self.lab_ck['DSS Assist'].config(state='active')
if field == 'Supercruise Assist':
if self.checkboxvar['Supercruise Assist'].get() == 1 and self.SC_A_running == False:
self.lab_ck['FSD Route Assist'].config(state='disabled')
self.lab_ck['AFK Combat Assist'].config(state='disabled')
self.lab_ck['Waypoint Assist'].config(state='disabled')
self.lab_ck['Robigo Assist'].config(state='disabled')
self.lab_ck['DSS Assist'].config(state='disabled')
self.start_sc()
elif self.checkboxvar['Supercruise Assist'].get() == 0 and self.SC_A_running == True:
self.stop_sc()
self.lab_ck['FSD Route Assist'].config(state='active')
self.lab_ck['AFK Combat Assist'].config(state='active')
self.lab_ck['Waypoint Assist'].config(state='active')
self.lab_ck['Robigo Assist'].config(state='active')
self.lab_ck['DSS Assist'].config(state='active')
if field == 'Waypoint Assist':
if self.checkboxvar['Waypoint Assist'].get() == 1 and self.WP_A_running == False:
self.lab_ck['FSD Route Assist'].config(state='disabled')
self.lab_ck['Supercruise Assist'].config(state='disabled')
self.lab_ck['AFK Combat Assist'].config(state='disabled')
self.lab_ck['Robigo Assist'].config(state='disabled')
self.lab_ck['DSS Assist'].config(state='disabled')
self.start_waypoint()
elif self.checkboxvar['Waypoint Assist'].get() == 0 and self.WP_A_running == True:
self.stop_waypoint()
self.lab_ck['FSD Route Assist'].config(state='active')
self.lab_ck['Supercruise Assist'].config(state='active')
self.lab_ck['AFK Combat Assist'].config(state='active')
self.lab_ck['Robigo Assist'].config(state='active')
self.lab_ck['DSS Assist'].config(state='active')
if field == 'Robigo Assist':
if self.checkboxvar['Robigo Assist'].get() == 1 and self.RO_A_running == False:
self.lab_ck['FSD Route Assist'].config(state='disabled')
self.lab_ck['Supercruise Assist'].config(state='disabled')
self.lab_ck['AFK Combat Assist'].config(state='disabled')
self.lab_ck['Waypoint Assist'].config(state='disabled')
self.lab_ck['DSS Assist'].config(state='disabled')
self.start_robigo()
elif self.checkboxvar['Robigo Assist'].get() == 0 and self.RO_A_running == True:
self.stop_robigo()
self.lab_ck['FSD Route Assist'].config(state='active')
self.lab_ck['Supercruise Assist'].config(state='active')
self.lab_ck['AFK Combat Assist'].config(state='active')
self.lab_ck['Waypoint Assist'].config(state='active')
self.lab_ck['DSS Assist'].config(state='active')
if field == 'AFK Combat Assist':
if self.checkboxvar['AFK Combat Assist'].get() == 1:
self.ed_ap.set_afk_combat_assist(True)
self.log_msg("AFK Combat Assist start")
self.lab_ck['FSD Route Assist'].config(state='disabled')
self.lab_ck['Supercruise Assist'].config(state='disabled')
self.lab_ck['Waypoint Assist'].config(state='disabled')
self.lab_ck['Robigo Assist'].config(state='disabled')
self.lab_ck['DSS Assist'].config(state='disabled')
elif self.checkboxvar['AFK Combat Assist'].get() == 0:
self.ed_ap.set_afk_combat_assist(False)
self.log_msg("AFK Combat Assist stop")
self.lab_ck['FSD Route Assist'].config(state='active')
self.lab_ck['Supercruise Assist'].config(state='active')
self.lab_ck['Waypoint Assist'].config(state='active')
self.lab_ck['Robigo Assist'].config(state='active')
self.lab_ck['DSS Assist'].config(state='active')
if field == 'DSS Assist':
if self.checkboxvar['DSS Assist'].get() == 1:
self.lab_ck['FSD Route Assist'].config(state='disabled')
self.lab_ck['AFK Combat Assist'].config(state='disabled')
self.lab_ck['Supercruise Assist'].config(state='disabled')
self.lab_ck['Waypoint Assist'].config(state='disabled')
self.lab_ck['Robigo Assist'].config(state='disabled')
self.start_dss()
elif self.checkboxvar['DSS Assist'].get() == 0:
self.stop_dss()
self.lab_ck['FSD Route Assist'].config(state='active')
self.lab_ck['Supercruise Assist'].config(state='active')
self.lab_ck['AFK Combat Assist'].config(state='active')
self.lab_ck['Waypoint Assist'].config(state='active')
self.lab_ck['Robigo Assist'].config(state='active')
if self.checkboxvar['Enable Randomness'].get():
self.ed_ap.set_randomness(True)
else:
self.ed_ap.set_randomness(False)
if self.checkboxvar['Activate Elite for each key'].get():
self.ed_ap.set_activate_elite_eachkey(True)
self.ed_ap.keys.activate_window=True
else:
self.ed_ap.set_activate_elite_eachkey(False)
self.ed_ap.keys.activate_window = False
if self.checkboxvar['Automatic logout'].get():
self.ed_ap.set_automatic_logout(True)
else:
self.ed_ap.set_automatic_logout(False)
if self.checkboxvar['Enable Overlay'].get():
self.ed_ap.set_overlay(True)
else:
self.ed_ap.set_overlay(False)
if self.checkboxvar['Enable Voice'].get():
self.ed_ap.set_voice(True)
else:
self.ed_ap.set_voice(False)
if self.checkboxvar['ELW Scanner'].get():
self.ed_ap.set_fss_scan(True)
else:
self.ed_ap.set_fss_scan(False)
if self.checkboxvar['Enable CV View'].get() == 1:
self.cv_view = True
x = self.root.winfo_x() + self.root.winfo_width() + 4
y = self.root.winfo_y()
self.ed_ap.set_cv_view(True, x, y)
else:
self.cv_view = False
self.ed_ap.set_cv_view(False)
self.ed_ap.config['DSSButton'] = self.radiobuttonvar['dss_button'].get()
if self.radiobuttonvar['debug_mode'].get() == "Error":
self.ed_ap.set_log_error(True)
elif self.radiobuttonvar['debug_mode'].get() == "Debug":
self.ed_ap.set_log_debug(True)
elif self.radiobuttonvar['debug_mode'].get() == "Info":
self.ed_ap.set_log_info(True)
if field == 'Single Waypoint Assist':
if self.checkboxvar['Single Waypoint Assist'].get() == 1 and self.SWP_A_running == False:
self.start_single_waypoint_assist()
elif self.checkboxvar['Single Waypoint Assist'].get() == 0 and self.SWP_A_running == True:
self.stop_single_waypoint_assist()
if field == 'Debug Overlay':
if self.checkboxvar['Debug Overlay'].get():
self.ed_ap.debug_overlay = True
else:
self.ed_ap.debug_overlay = False
self.ed_ap.config['AFKCombat_AttackAtWill'] = self.checkboxvar['AFKCombat AttackAtWill'].get()
self.ed_ap.config['HotkeysEnable'] = self.checkboxvar['Enable Hotkeys'].get()
if field == 'Debug OCR':
self.ed_ap.debug_ocr = self.checkboxvar['Debug OCR'].get()
if field == 'Debug Images':
self.ed_ap.debug_images = self.checkboxvar['Debug Images'].get()
def makeform(self, win, ftype, fields, r: int = 0, inc: float = 1, r_from: float = 0, rto: float = 1000):
entries = {}
win.columnconfigure(1, weight=1)
for field in fields:
if ftype == FORM_TYPE_CHECKBOX:
self.checkboxvar[field] = tk.IntVar()
lab = ttk.Checkbutton(win, text=field, variable=self.checkboxvar[field], command=(lambda field=field: self.check_cb(field)))
self.lab_ck[field] = lab
lab.grid(row=r, column=0, columnspan=2, padx=2, pady=2, sticky=tk.W)
else:
lab = ttk.Label(win, text=field + ": ")
if ftype == FORM_TYPE_SPINBOX:
ent = ttk.Spinbox(win, width=10, from_=r_from, to=rto, increment=inc, justify=tk.RIGHT)
else:
ent = ttk.Entry(win, width=10, justify=tk.RIGHT)
ent.bind('<FocusOut>', self.entry_update)
ent.insert(0, "0")
lab.grid(row=r, column=0, padx=2, pady=2, sticky=tk.W)
ent.grid(row=r, column=1, padx=2, pady=2, sticky=tk.E)
entries[field] = ent
lab = ToolTip(lab, msg=self.tooltips[field], delay=1.0, bg="#808080", fg="#FFFFFF")
r += 1
return entries
# OCR calibration methods moved to before __init__
def on_region_select(self, event):
selected_region = self.calibration_region_var.get()
if selected_region in self.ocr_calibration_data:
rect = self.ocr_calibration_data[selected_region]['rect']
self.calibration_rect_label_var.set(f"[{rect[0]:.4f}, {rect[1]:.4f}, {rect[2]:.4f}, {rect[3]:.4f}]")
self.calibration_rect_text_var.set(f"{self.ocr_calibration_data[selected_region].get('text','')}")
self.calibration_rect_left_var.set(rect[0])
self.calibration_rect_top_var.set(rect[1])
self.calibration_rect_right_var.set(rect[2])
self.calibration_rect_bottom_var.set(rect[3])
reg_f = Quad.from_rect(rect)
self.ed_ap.overlay.overlay_quad_pct('region select', reg_f, (0, 255, 0), 2, 15)
self.ed_ap.overlay.overlay_paint()
def on_region_size_change(self):
# Check if variables are valid
l_str = self.calibration_rect_left_var.get()
t_str = self.calibration_rect_top_var.get()
r_str = self.calibration_rect_right_var.get()
b_str = self.calibration_rect_bottom_var.get()
# Check if any are empty
if l_str == '' or r_str == '' or t_str == '' or b_str == '':
return
selected_region = self.calibration_region_var.get()
if selected_region in self.ocr_calibration_data:
rect = self.ocr_calibration_data[selected_region]['rect']
rect[0] = str_to_float(l_str)
rect[1] = str_to_float(t_str)
rect[2] = str_to_float(r_str)
rect[3] = str_to_float(b_str)
self.calibration_rect_label_var.set(f"[{rect[0]:.4f}, {rect[1]:.4f}, {rect[2]:.4f}, {rect[3]:.4f}]")
self.calibration_rect_text_var.set(f"{self.ocr_calibration_data[selected_region].get('text','')}")
reg_f = Quad.from_rect(rect)
self.ed_ap.overlay.overlay_quad_pct('region select', reg_f, (0, 255, 0), 2, 15)
self.ed_ap.overlay.overlay_paint()
@staticmethod
def calibrate_region_help():
# TODO - delete first line and enable the second.
webbrowser.open_new("https://github.com/Stumpii/EDAPGui/blob/main/docs/Calibration.md")
# webbrowser.open_new("https://github.com/SumZer0-git/EDAPGui/blob/main/docs/Calibration.md")
def create_calibration_tab(self, tab):
self.load_ocr_calibration_data()
tab.columnconfigure(0, weight=1)
# Region Calibration
blk_region_cal = ttk.LabelFrame(tab, text="Region Calibration")
blk_region_cal.grid(row=0, column=0, padx=10, pady=5, sticky="NSEW")
blk_region_cal.columnconfigure(1, weight=1)
region_keys = sorted([key for key, value in self.ocr_calibration_data.items() if isinstance(value, dict) and 'rect' in value and 'compass' not in key and 'target' not in key])
self.calibration_region_var = tk.StringVar()
self.calibration_region_combo = ttk.Combobox(blk_region_cal, textvariable=self.calibration_region_var, values=region_keys)
self.calibration_region_combo.grid(row=0, column=1, padx=5, pady=5, sticky="EW")
self.calibration_region_combo.bind("<<ComboboxSelected>>", self.on_region_select)
ttk.Label(blk_region_cal, text="Region:").grid(row=0, column=0, padx=5, pady=5, sticky=tk.W)
ttk.Label(blk_region_cal, text="Procedure:").grid(row=1, column=0, padx=5, pady=5, sticky="NW")
self.calibration_rect_text_var = tk.StringVar()
ttk.Label(blk_region_cal, textvariable=self.calibration_rect_text_var).grid(row=1, column=1, padx=5, pady=5, sticky=tk.W)
ttk.Label(blk_region_cal, text="Rect:").grid(row=2, column=0, padx=5, pady=5, sticky=tk.W)
self.calibration_rect_label_var = tk.StringVar()
ttk.Label(blk_region_cal, textvariable=self.calibration_rect_label_var).grid(row=2, column=1, padx=5, pady=5, sticky=tk.W)
ttk.Label(blk_region_cal, text="Manually change the region below and save.\nHint: You can also use your keyboard up and down arrow keys.").grid(row=3, column=0, columnspan=2, padx=5, pady=5, sticky=tk.W)
self.calibration_rect_left_var = tk.StringVar()
lbl_calibration_rect_left = ttk.Label(blk_region_cal, text='Left:')
lbl_calibration_rect_left.grid(row=4, column=0, padx=5, pady=5, sticky=tk.W)
spn_calibration_rect_left = ttk.Spinbox(blk_region_cal, textvariable=self.calibration_rect_left_var, width=10, from_=0, to=1, increment=0.001, justify=tk.RIGHT, command=self.on_region_size_change)
spn_calibration_rect_left.grid(row=4, column=1, padx=5, pady=5, sticky=tk.W)
self.calibration_rect_top_var = tk.StringVar()
lbl_calibration_rect_top = ttk.Label(blk_region_cal, text='Top:')
lbl_calibration_rect_top.grid(row=5, column=0, padx=5, pady=5, sticky=tk.W)
spn_calibration_rect_top = ttk.Spinbox(blk_region_cal, textvariable=self.calibration_rect_top_var, width=10, from_=0, to=1, increment=0.001, justify=tk.RIGHT, command=self.on_region_size_change)
spn_calibration_rect_top.grid(row=5, column=1, padx=5, pady=5, sticky=tk.W)
self.calibration_rect_right_var = tk.StringVar()
lbl_calibration_rect_right = ttk.Label(blk_region_cal, text='Right:')
lbl_calibration_rect_right.grid(row=6, column=0, padx=5, pady=5, sticky=tk.W)
spn_calibration_rect_right = ttk.Spinbox(blk_region_cal, textvariable=self.calibration_rect_right_var, width=10, from_=0, to=1, increment=0.001, justify=tk.RIGHT, command=self.on_region_size_change)
spn_calibration_rect_right.grid(row=6, column=1, padx=5, pady=5, sticky=tk.W)
self.calibration_rect_bottom_var = tk.StringVar()
lbl_calibration_rect_bottom = ttk.Label(blk_region_cal, text='Bottom:')
lbl_calibration_rect_bottom.grid(row=7, column=0, padx=5, pady=5, sticky=tk.W)
spn_calibration_rect_bottom = ttk.Spinbox(blk_region_cal, textvariable=self.calibration_rect_bottom_var, width=10, from_=0, to=1, increment=0.001, justify=tk.RIGHT, command=self.on_region_size_change)
spn_calibration_rect_bottom.grid(row=7, column=1, padx=5, pady=5, sticky=tk.W)
# ttk.Button(blk_region_cal, text="Calibrate Region", command=self.calibrate_ocr_region).grid(row=8, column=0, padx=5, pady=10, sticky=tk.W)
ttk.Button(blk_region_cal, text="Calibrate Region help online", command=self.calibrate_region_help).grid(row=8, column=0, padx=5, pady=10, sticky=tk.W)