-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocknet_aio_monitor.py
1671 lines (1469 loc) · 89.6 KB
/
blocknet_aio_monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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 asyncio
# import cProfile
import logging
import shutil
import signal
import time
import CTkToolTip
import customtkinter as ctk
import custom_tk_mods.ctkInputDialogMod as ctkInputDialogMod
import custom_tk_mods.ctkCheckBox as ctkCheckBoxMod
import json
from psutil import process_iter
from PIL import Image
import PIL._tkinter_finder
from threading import Thread, enumerate, current_thread
from cryptography.fernet import Fernet
from blockdx import BlockdxUtility
from blocknet_core import BlocknetUtility
from xlite import XliteUtility
from conf_data import (blockdx_selectedWallets_blocknet, blockdx_bin_path, blocknet_bin_path, xlite_bin_path)
from widgets_strings import *
from global_variables import *
asyncio_logger = logging.getLogger('asyncio')
asyncio_logger.setLevel(logging.WARNING)
pil_logger = logging.getLogger('PIL')
pil_logger.setLevel(logging.WARNING)
button_width = 120
gui_width = 400
panel_checkboxes_width = 165
tooltip_bg_color = ("#ebebeb", "#051937")
# ctk.set_appearance_mode("system")
# ctk.set_default_color_theme("dark-blue")
ctk.set_default_color_theme(themepath)
class BlocknetGUI(ctk.CTk):
def __init__(self):
super().__init__()
self.install_greyed_img = None
self.install_img = None
self.delete_greyed_img = None
self.delete_img = None
self.stop_greyed_img = None
self.stop_img = None
self.start_greyed_img = None
self.start_img = None
self.transparent_img = None
self.theme_img = None
self.blocknet_version = [blocknet_release_url.split('/')[7]]
self.blockdx_version = [blockdx_release_url.split('/')[7]]
self.xlite_version = [xlite_release_url.split('/')[7]]
self.last_process_check_time = None
self.disable_daemons_conf_check = False
self.is_blockdx_config_sync = None
# threads
self.update_status_process_folder_thread = None
self.download_xlite_thread = None
self.download_blockdx_thread = None
self.download_blocknet_thread = None
self.update_status_gui_thread = None
self.blocknet_t1 = None
self.blocknet_t2 = None
self.xlite_t2 = None
self.xlite_t1 = None
self.blockdx_t2 = None
self.blockdx_t1 = None
self.bootstrap_thread = None
self.cfg = load_cfg_json()
self.adjust_theme()
custom_path = None
self.xlite_password = None
if self.cfg:
if 'custom_path' in self.cfg:
custom_path = self.cfg['custom_path']
if 'salt' in self.cfg and 'xl_pass' in self.cfg:
# logging.info(f"xlite password: {self.cfg['xl_pass']} {self.cfg['salt'].encode()}")
try:
self.xlite_password = decrypt_password(self.cfg['xl_pass'], self.cfg['salt'].encode())
except Exception as e:
logging.error(f"Error decrypting XLite password: {e}")
self.xlite_password = None
self.blocknet_utility = BlocknetUtility(custom_path=custom_path)
self.blockdx_utility = BlockdxUtility()
self.xlite_utility = XliteUtility()
# binaries frame
self.bins_title_frame = None
self.bins_install_delete_xlite_string_var = None
self.bins_install_delete_blockdx_string_var = None
self.bins_install_delete_blocknet_string_var = None
self.xlite_bin_installed_boolvar = None
self.blockdx_bin_installed_boolvar = None
self.blocknet_bin_installed_boolvar = None
self.bins_found_label = None
self.bins_xlite_label = None
self.bins_blockdx_label = None
self.bins_blocknet_label = None
self.bins_header_label = None
self.bins_install_delete_xlite_tooltip = None
self.bins_install_delete_blockdx_tooltip = None
self.bins_install_delete_blocknet_tooltip = None
self.bins_xlite_found_checkbox = None
self.bins_blockdx_found_checkbox = None
self.bins_blocknet_found_checkbox = None
self.bins_xlite_version_optionmenu = None
self.bins_blockdx_version_optionmenu = None
self.bins_blocknet_version_optionmenu = None
self.bins_button_switch_theme = None
self.bins_install_delete_blocknet_button = None
self.bins_install_delete_blockdx_button = None
self.bins_install_delete_xlite_button = None
self.bins_last_aio_folder_check_time = None
self.xlite_start_close_button_tooltip = None
self.blockdx_start_close_button_tooltip = None
self.blocknet_start_close_button_tooltip = None
# blocknet
self.blocknet_download_bootstrap_button = None
self.blocknet_download_bootstrap_string_var = None
self.blocknet_data_path_entry_string_var = None
self.blocknet_conf_status_checkbox_string_var = None
self.blocknet_start_close_button_string_var = None
self.blocknet_data_path_status_checkbox_string_var = None
self.blocknet_process_status_checkbox_string_var = None
self.blocknet_rpc_connection_checkbox_string_var = None
self.blocknet_core_label = None
self.blocknet_check_config_button = None
self.blocknet_custom_path_button = None
self.blocknet_start_close_button = None
self.blocknet_conf_status_checkbox = None
self.blocknet_conf_status_checkbox_state = None
self.blocknet_data_path_entry = None
self.blocknet_data_path_label = None
self.blocknet_data_path_status_checkbox = None
self.blocknet_data_path_status_checkbox_state = None
self.blocknet_process_running = False
self.blocknet_process_status_checkbox = None
self.blocknet_process_status_checkbox_state = None
self.blocknet_rpc_connection_checkbox = None
self.blocknet_rpc_connection_checkbox_state = None
# block-dx
self.blockdx_process_status_checkbox_string_var = None
self.blockdx_start_close_button_string_var = None
self.blockdx_valid_config_checkbox_string_var = None
self.blockdx_label = None
self.blockdx_check_config_button = None
self.blockdx_start_close_button = None
self.disable_start_blockdx_button = False
self.disable_start_blocknet_button = False
self.blockdx_process_status_checkbox = None
self.blockdx_process_status_checkbox_state = None
self.blockdx_valid_config_checkbox = None
self.blockdx_valid_config_checkbox_state = None
self.blockdx_process_running = False
# xlite
self.disable_start_xlite_button = False
self.xlite_label = None
self.xlite_process_running = False
self.xlite_process_status_checkbox = None
self.xlite_process_status_checkbox_state = None
self.xlite_process_status_checkbox_string_var = None
self.xlite_check_config_button = None
self.xlite_check_config_button_string_var = None
self.xlite_reverse_proxy_process_status_checkbox = None
self.xlite_reverse_proxy_process_status_checkbox_state = None
self.xlite_reverse_proxy_process_status_checkbox_string_var = None
self.xlite_start_close_button = None
self.xlite_start_close_button_string_var = None
self.xlite_store_password_button = None
self.xlite_store_password_button_string_var = None
self.xlite_valid_config_checkbox = None
self.xlite_valid_config_checkbox_state = None
self.xlite_valid_config_checkbox_string_var = None
# xlite-daemon
self.xlite_daemon_process_running = False
self.xlite_daemon_process_status_checkbox = None
self.xlite_daemon_process_status_checkbox_state = None
self.xlite_daemon_process_status_checkbox_string_var = None
self.xlite_daemon_valid_config_checkbox = None
self.xlite_daemon_valid_config_checkbox_state = None
self.xlite_daemon_valid_config_checkbox_string_var = None
self.time_disable_button = 3000
# frames
self.bins_download_frame = None
self.blocknet_core_frame = None
self.blocknet_title_frame = None
self.blockdx_frame = None
self.blockdx_title_frame = None
self.xlite_frame = None
self.xlite_title_frame = None
self.init_setup()
async def setup_management_sections(self):
await asyncio.gather(
self.setup_bin(),
self.setup_blocknet_core(),
self.setup_blockdx(),
self.setup_xlite()
)
def init_setup(self):
self.title(app_title_string)
self.resizable(False, False)
self.setup_load_images()
self.init_frames()
# Call functions to setup management sections
asyncio.run(self.setup_management_sections())
self.setup_tooltips()
self.init_grid()
self.update_status_gui_thread = Thread(target=self.update_status_gui, daemon=True)
self.update_status_gui_thread.start()
self.update_status_process_folder_thread = Thread(target=self.update_status_process_folder, daemon=True)
self.update_status_process_folder_thread.start()
# Bind the close event to the on_close method
self.protocol("WM_DELETE_WINDOW", self.on_close)
signal.signal(signal.SIGINT, self.handle_signal)
signal.signal(signal.SIGTERM, self.handle_signal)
def init_frames(self):
self.bins_download_frame = ctk.CTkFrame(master=self)
self.bins_title_frame = ctk.CTkFrame(self.bins_download_frame)
self.blocknet_core_frame = ctk.CTkFrame(master=self)
self.blocknet_title_frame = ctk.CTkFrame(self.blocknet_core_frame)
self.blockdx_frame = ctk.CTkFrame(master=self)
self.blockdx_title_frame = ctk.CTkFrame(self.blockdx_frame)
self.xlite_frame = ctk.CTkFrame(master=self)
self.xlite_title_frame = ctk.CTkFrame(self.xlite_frame)
def setup_load_images(self):
resize = (65, 30)
self.theme_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "light.png")).resize(resize, PIL.Image.LANCZOS),
dark_image=PIL.Image.open(os.path.join(DIRPATH, "img", "dark.png")).resize(resize, PIL.Image.LANCZOS),
size=resize)
resize = (50, 50)
self.transparent_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "transparent.png")).resize(resize,
PIL.Image.LANCZOS))
self.start_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "start-50.png")).resize(resize, PIL.Image.LANCZOS))
self.start_greyed_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "start-50_greyed.png")).resize(resize,
PIL.Image.LANCZOS))
self.stop_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "stop-50.png")).resize(resize, PIL.Image.LANCZOS))
self.stop_greyed_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "stop-50_greyed.png")).resize(resize,
PIL.Image.LANCZOS))
self.delete_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "delete-50.png")).resize(resize, PIL.Image.LANCZOS))
self.delete_greyed_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "delete-50_greyed.png")).resize(resize,
PIL.Image.LANCZOS))
self.install_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "installer-50.png")).resize(resize,
PIL.Image.LANCZOS))
self.install_greyed_img = ctk.CTkImage(
light_image=PIL.Image.open(os.path.join(DIRPATH, "img", "installer-50_greyed.png")).resize(resize,
PIL.Image.LANCZOS))
async def setup_bin(self):
self.bins_header_label = ctk.CTkLabel(self.bins_title_frame,
text="Binaries Control panel:") # width=155,
# Add an empty column between the header label and the found label
self.bins_title_frame.columnconfigure(1, weight=1)
self.bins_found_label = ctk.CTkLabel(self.bins_title_frame,
text="Found:",
anchor='s')
# self.bins_found_label.grid(row=0, column=2, padx=(0, 30), pady=5)
# os.path.join(aio_folder, "img", "dark.png")
# bg_color = self.bins_title_frame.cget('fg_color')
self.bins_button_switch_theme = ctk.CTkButton(self.bins_title_frame,
image=self.theme_img,
command=self.switch_theme_command,
text='',
fg_color='transparent',
hover=False,
width=1)
# self.bin_title_frame.columnconfigure(3, weight=1)
# Creating labels
self.bins_blocknet_label = ctk.CTkLabel(self.bins_download_frame, text="Blocknet Core:")
self.bins_blockdx_label = ctk.CTkLabel(self.bins_download_frame, text="Block-DX:")
self.bins_xlite_label = ctk.CTkLabel(self.bins_download_frame, text="Xlite:")
self.blocknet_bin_installed_boolvar = ctk.BooleanVar(value=False)
self.blockdx_bin_installed_boolvar = ctk.BooleanVar(value=False)
self.xlite_bin_installed_boolvar = ctk.BooleanVar(value=False)
self.bins_blocknet_version_optionmenu = ctk.CTkOptionMenu(self.bins_download_frame,
values=self.blocknet_version,
state='disabled')
self.bins_blockdx_version_optionmenu = ctk.CTkOptionMenu(self.bins_download_frame,
values=self.blockdx_version,
state='disabled')
self.bins_xlite_version_optionmenu = ctk.CTkOptionMenu(self.bins_download_frame,
values=self.xlite_version,
state='disabled')
self.bins_blocknet_found_checkbox = ctkCheckBoxMod.CTkCheckBox(self.bins_download_frame,
text='',
variable=self.blocknet_bin_installed_boolvar,
state='disabled',
corner_radius=25, width=1)
self.bins_blockdx_found_checkbox = ctkCheckBoxMod.CTkCheckBox(self.bins_download_frame,
text='',
variable=self.blockdx_bin_installed_boolvar,
state='disabled',
corner_radius=25)
self.bins_xlite_found_checkbox = ctkCheckBoxMod.CTkCheckBox(self.bins_download_frame,
text='',
variable=self.xlite_bin_installed_boolvar,
state='disabled',
corner_radius=25)
bin_button_width = 90
self.bins_install_delete_blocknet_string_var = ctk.StringVar(value='')
self.bins_install_delete_blocknet_button = ctk.CTkButton(self.bins_download_frame,
state='normal', image=self.transparent_img,
command=self.install_delete_blocknet_command,
# text="",
width=bin_button_width,
textvariable=self.bins_install_delete_blocknet_string_var,
corner_radius=25)
self.bins_install_delete_blockdx_string_var = ctk.StringVar(value='')
self.bins_install_delete_blockdx_button = ctk.CTkButton(self.bins_download_frame,
state='normal', image=self.transparent_img,
command=self.install_delete_blockdx_command,
textvariable=self.bins_install_delete_blockdx_string_var,
width=bin_button_width,
# text="",
corner_radius=25)
self.bins_install_delete_xlite_string_var = ctk.StringVar(value='')
self.bins_install_delete_xlite_button = ctk.CTkButton(self.bins_download_frame,
state='normal',
image=self.transparent_img,
command=self.install_delete_xlite_command,
textvariable=self.bins_install_delete_xlite_string_var,
width=bin_button_width,
# text="",
corner_radius=25)
self.blocknet_start_close_button_string_var = ctk.StringVar(value='')
self.blocknet_start_close_button = ctk.CTkButton(self.bins_download_frame,
image=self.transparent_img,
# textvariable=self.blocknet_start_close_button_string_var,
width=bin_button_width,
text="",
command=self.start_or_close_blocknet,
corner_radius=25)
self.blockdx_start_close_button_string_var = ctk.StringVar(value='')
self.blockdx_start_close_button = ctk.CTkButton(self.bins_download_frame,
image=self.transparent_img,
# textvariable=self.blockdx_start_close_button_string_var,
width=bin_button_width,
text="",
command=self.start_or_close_blockdx,
corner_radius=25)
self.xlite_start_close_button_string_var = ctk.StringVar(value='')
self.xlite_start_close_button = ctk.CTkButton(self.bins_download_frame,
image=self.transparent_img,
# textvariable=self.xlite_start_close_button_string_var,
width=bin_button_width,
text="",
command=self.start_or_close_xlite,
corner_radius=25)
async def setup_blocknet_core(self):
# Frame for Data Path label and entry
# Add widgets for Blocknet Core management inside the blocknet_core_frame
# Label for Blocknet Core frame
width = 350
self.blocknet_core_label = ctk.CTkLabel(self.blocknet_title_frame,
text=blocknet_frame_title_string,
width=width,
anchor="w")
# Label for Data Path
self.blocknet_data_path_label = ctk.CTkLabel(self.blocknet_title_frame, text="Data Path: ")
width = 343
self.blocknet_data_path_entry_string_var = ctk.StringVar(value=self.blocknet_utility.data_folder)
self.blocknet_data_path_entry = ctk.CTkEntry(self.blocknet_title_frame,
textvariable=self.blocknet_data_path_entry_string_var,
state='normal',
width=width)
self.blocknet_data_path_entry.configure(state='readonly')
# Button for setting custom path
self.blocknet_custom_path_button = ctk.CTkButton(self.blocknet_title_frame,
text=blocknet_set_custom_path_string,
command=self.open_custom_path_dialog,
width=button_width)
# Button for downloading blocknet bootstrap
self.blocknet_download_bootstrap_string_var = ctk.StringVar(value="")
self.blocknet_download_bootstrap_button = ctk.CTkButton(self.blocknet_title_frame,
image=self.transparent_img,
textvariable=self.blocknet_download_bootstrap_string_var,
command=self.download_bootstrap_command,
width=button_width)
# Checkboxes
width_mod = 15
self.blocknet_data_path_status_checkbox_state = ctk.BooleanVar()
self.blocknet_data_path_status_checkbox_string_var = ctk.StringVar(value="Data Path")
self.blocknet_data_path_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blocknet_core_frame,
textvariable=self.blocknet_data_path_status_checkbox_string_var,
variable=self.blocknet_data_path_status_checkbox_state,
state='disabled',
corner_radius=25,
width=panel_checkboxes_width + width_mod) # , disabledforeground='black')
self.blocknet_process_status_checkbox_state = ctk.BooleanVar()
self.blocknet_process_status_checkbox_string_var = ctk.StringVar(value='')
self.blocknet_process_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blocknet_core_frame,
textvariable=self.blocknet_process_status_checkbox_string_var,
variable=self.blocknet_process_status_checkbox_state,
state='disabled',
corner_radius=25,
width=panel_checkboxes_width + width_mod) # , disabledforeground='black')
self.blocknet_conf_status_checkbox_state = ctk.BooleanVar()
self.blocknet_conf_status_checkbox_string_var = ctk.StringVar(value='')
self.blocknet_conf_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blocknet_core_frame,
textvariable=self.blocknet_conf_status_checkbox_string_var,
variable=self.blocknet_conf_status_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width) # , disabledforeground='black')
self.blocknet_rpc_connection_checkbox_state = ctk.BooleanVar()
self.blocknet_rpc_connection_checkbox_string_var = ctk.StringVar(value='')
self.blocknet_rpc_connection_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blocknet_core_frame,
textvariable=self.blocknet_rpc_connection_checkbox_string_var,
variable=self.blocknet_rpc_connection_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width) # , disabledforeground='black')
# Button for starting or closing Blocknet
# Button for checking config
# self.blocknet_check_config_button = ctk.CTkButton(self.blocknet_core_frame,
# text=check_config_string,
# command=self.blocknet_check_config,
# width=button_width)
# self.blocknet_check_config_button.grid(row=3, column=3, sticky="e")
async def setup_blockdx(self):
# Label for Block-dx frame
width = 540
self.blockdx_label = ctk.CTkLabel(self.blockdx_title_frame,
text=blockdx_frame_title_string,
anchor='w',
width=width)
# Checkboxes
width_mod = 35
self.blockdx_process_status_checkbox_state = ctk.BooleanVar()
self.blockdx_process_status_checkbox_string_var = ctk.StringVar(value='')
self.blockdx_process_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blockdx_frame,
textvariable=self.blockdx_process_status_checkbox_string_var,
variable=self.blockdx_process_status_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width - width_mod)
self.blockdx_valid_config_checkbox_state = ctk.BooleanVar()
self.blockdx_valid_config_checkbox_string_var = ctk.StringVar(value='')
self.blockdx_valid_config_checkbox = ctkCheckBoxMod.CTkCheckBox(self.blockdx_frame,
textvariable=self.blockdx_valid_config_checkbox_string_var,
variable=self.blockdx_valid_config_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width - width_mod) # , disabledforeground='black')
async def setup_xlite(self):
width = 415
self.xlite_label = ctk.CTkLabel(self.xlite_title_frame, text=xlite_frame_title_string, width=width, anchor='w')
# Checkboxes
self.xlite_process_status_checkbox_state = ctk.BooleanVar()
self.xlite_process_status_checkbox_string_var = ctk.StringVar(value='')
self.xlite_process_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.xlite_frame,
textvariable=self.xlite_process_status_checkbox_string_var,
variable=self.xlite_process_status_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width)
self.xlite_daemon_process_status_checkbox_state = ctk.BooleanVar()
self.xlite_daemon_process_status_checkbox_string_var = ctk.StringVar(value='')
self.xlite_daemon_process_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.xlite_frame,
textvariable=self.xlite_daemon_process_status_checkbox_string_var,
variable=self.xlite_daemon_process_status_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width)
self.xlite_reverse_proxy_process_status_checkbox_state = ctk.BooleanVar()
self.xlite_reverse_proxy_process_status_checkbox_string_var = ctk.StringVar(
value=xlite_reverse_proxy_not_running_string)
self.xlite_reverse_proxy_process_status_checkbox = ctkCheckBoxMod.CTkCheckBox(self.xlite_frame,
textvariable=self.xlite_reverse_proxy_process_status_checkbox_string_var,
variable=self.xlite_reverse_proxy_process_status_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width)
self.xlite_valid_config_checkbox_state = ctk.BooleanVar()
self.xlite_valid_config_checkbox_string_var = ctk.StringVar(value='')
self.xlite_valid_config_checkbox = ctkCheckBoxMod.CTkCheckBox(self.xlite_frame,
textvariable=self.xlite_valid_config_checkbox_string_var,
variable=self.xlite_valid_config_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width)
self.xlite_daemon_valid_config_checkbox_state = ctk.BooleanVar()
self.xlite_daemon_valid_config_checkbox_string_var = ctk.StringVar(value='')
self.xlite_daemon_valid_config_checkbox = ctkCheckBoxMod.CTkCheckBox(self.xlite_frame,
textvariable=self.xlite_daemon_valid_config_checkbox_string_var,
variable=self.xlite_daemon_valid_config_checkbox_state,
corner_radius=25,
state='disabled',
width=panel_checkboxes_width)
# Button for refreshing Xlite config data
# self.xlite_check_config_button_string_var = ctk.StringVar(value=check_config_string)
# self.xlite_check_config_button = ctk.CTkButton(self.xlite_frame,
# textvariable=self.xlite_check_config_button_string_var,
# command=self.refresh_xlite_confs, width=button_width)
# self.xlite_check_config_button.grid(row=1, column=1, sticky="e")
# Create the Button widget with a text variable
self.xlite_store_password_button_string_var = ctk.StringVar(value='')
self.xlite_store_password_button = ctk.CTkButton(self.xlite_title_frame,
textvariable=self.xlite_store_password_button_string_var,
width=button_width)
# Bind left-click event
self.xlite_store_password_button.bind("<Button-1>",
lambda event: self.xlite_store_password_button_mouse_click(event))
# Bind right-click event
self.xlite_store_password_button.bind("<Button-3>",
lambda event: self.xlite_store_password_button_mouse_click(event))
# Set button command for normal button clicks
self.xlite_store_password_button.configure(command=self.xlite_store_password_button_mouse_click)
def setup_tooltips(self):
CTkToolTip.CTkToolTip(self.blocknet_core_frame, message=tooltip_howtouse, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.blockdx_frame, message=tooltip_howtouse, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.xlite_frame, message=tooltip_howtouse, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.bins_download_frame, message=tooltip_howtouse, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.bins_title_frame, message=tooltip_bins_title_msg, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.bins_header_label, message=tooltip_bins_title_msg, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.xlite_label, message=tooltip_xlite_label_msg, delay=1.0, border_width=2, follow=True,
bg_color=tooltip_bg_color)
CTkToolTip.CTkToolTip(self.bins_blocknet_label,
message=tooltip_blocknet_core_label_msg, delay=1, follow=True, bg_color=tooltip_bg_color,
border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.bins_blockdx_label, message=tooltip_blockdx_label_msg, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.bins_xlite_label, message=tooltip_xlite_label_msg, delay=1, follow=True,
bg_color=tooltip_bg_color, border_width=2, justify="left")
self.bins_install_delete_blocknet_tooltip = CTkToolTip.CTkToolTip(self.bins_install_delete_blocknet_button,
message='', delay=1, width=1, follow=True,
bg_color=tooltip_bg_color,
border_width=2, justify="left")
self.bins_install_delete_blockdx_tooltip = CTkToolTip.CTkToolTip(self.bins_install_delete_blockdx_button,
message=blockdx_release_url,
delay=1, width=1, follow=True,
bg_color=tooltip_bg_color,
border_width=2, justify="left")
self.bins_install_delete_xlite_tooltip = CTkToolTip.CTkToolTip(self.bins_install_delete_xlite_button,
message=xlite_release_url,
delay=1, follow=True, bg_color=tooltip_bg_color,
border_width=2, justify="left")
self.blocknet_start_close_button_tooltip = CTkToolTip.CTkToolTip(self.blocknet_start_close_button,
delay=1, follow=True,
bg_color=tooltip_bg_color,
border_width=2, justify="left")
self.blockdx_start_close_button_tooltip = CTkToolTip.CTkToolTip(self.blockdx_start_close_button,
delay=1, follow=True,
bg_color=tooltip_bg_color,
border_width=2, justify="left")
self.xlite_start_close_button_tooltip = CTkToolTip.CTkToolTip(self.xlite_start_close_button,
delay=1, follow=True,
bg_color=tooltip_bg_color,
border_width=2, justify="left")
CTkToolTip.CTkToolTip(self.blocknet_core_label,
message=tooltip_blocknet_core_label_msg,
delay=1.0, border_width=2, follow=True, bg_color=tooltip_bg_color)
CTkToolTip.CTkToolTip(self.blockdx_label,
message=tooltip_blockdx_label_msg,
delay=1.0, border_width=2, follow=True, bg_color=tooltip_bg_color)
def init_grid(self):
x = 0
y = 0
padx_main_frame = 10
pady_main_frame = 5
check_boxes_sticky = "ew"
self.grid_frames(x, y, padx_main_frame, pady_main_frame)
self.grid_bins_frame(x, y)
self.grid_blocknet_frame(x, y, check_boxes_sticky)
self.grid_blockdx_frame(x, y, check_boxes_sticky)
self.grid_xlite_frame(x, y, check_boxes_sticky)
def grid_frames(self, x, y, padx_main_frame, pady_main_frame):
self.bins_download_frame.grid(row=x, column=y, padx=padx_main_frame, pady=pady_main_frame, sticky="nsew")
self.bins_title_frame.grid(row=x, column=y, columnspan=5, padx=5, pady=5, sticky="ew")
self.blocknet_core_frame.grid(row=x + 1, column=y, padx=padx_main_frame, pady=pady_main_frame, sticky="nsew")
self.blocknet_title_frame.grid(row=x, column=y, columnspan=5, padx=5, pady=5, sticky="ew")
self.blockdx_frame.grid(row=x + 2, column=y, padx=padx_main_frame, pady=pady_main_frame, sticky="nsew")
self.blockdx_title_frame.grid(row=0, column=0, columnspan=3, padx=(5, 2), pady=5, sticky="ew")
self.xlite_frame.grid(row=x + 3, column=y, padx=padx_main_frame, pady=pady_main_frame, sticky="nsew")
self.xlite_title_frame.grid(row=0, column=0, columnspan=4, padx=5, pady=5, sticky="ew")
def grid_bins_frame(self, x, y):
# bin
self.bins_header_label.grid(row=x, column=y, padx=5, pady=0, sticky="nw")
self.bins_button_switch_theme.grid(row=x, column=y + 5, padx=2, pady=2, sticky='e')
self.bins_blocknet_label.grid(row=x + 1, column=y, padx=5, pady=2, sticky="e")
self.bins_blockdx_label.grid(row=x + 2, column=y, padx=5, pady=2, sticky="e")
self.bins_xlite_label.grid(row=x + 3, column=y, padx=5, pady=(2, 5), sticky="e")
sticky = 'ew'
self.bins_blocknet_version_optionmenu.grid(row=x + 1, column=y + 1, padx=5, sticky=sticky)
self.bins_blockdx_version_optionmenu.grid(row=x + 2, column=y + 1, padx=5, sticky=sticky)
self.bins_xlite_version_optionmenu.grid(row=x + 3, column=y + 1, padx=5, pady=(2, 5), sticky=sticky)
self.bins_blocknet_found_checkbox.grid(row=x + 1, column=y + 2, padx=5, sticky=sticky)
self.bins_blockdx_found_checkbox.grid(row=x + 2, column=y + 2, padx=5, sticky=sticky)
self.bins_xlite_found_checkbox.grid(row=x + 3, column=y + 2, padx=5, pady=(2, 5), sticky=sticky)
button_sticky = 'ew'
padx_main_frame = (70, 8)
self.bins_install_delete_blocknet_button.grid(row=x + 1, column=y + 3, padx=padx_main_frame,
sticky=button_sticky)
self.bins_install_delete_blockdx_button.grid(row=x + 2, column=y + 3, padx=padx_main_frame,
sticky=button_sticky)
self.bins_install_delete_xlite_button.grid(row=x + 3, column=y + 3, padx=padx_main_frame, pady=(2, 5),
sticky=button_sticky)
padx_main_frame = (8, 8)
self.blocknet_start_close_button.grid(row=x + 1, column=y + 4, padx=padx_main_frame, sticky='e')
# Button for starting or closing Block-dx
self.blockdx_start_close_button.grid(row=x + 2, column=y + 4, padx=padx_main_frame, sticky='e')
# Button for starting or closing Xlite
self.xlite_start_close_button.grid(row=x + 3, column=y + 4, padx=padx_main_frame, pady=(2, 5), sticky='e')
def grid_blocknet_frame(self, x, y, check_boxes_sticky):
# blocknet-core
self.blocknet_core_label.grid(row=x, column=y, columnspan=2, padx=5, pady=0, sticky="w")
self.blocknet_data_path_label.grid(row=x + 1, column=y, padx=5, pady=5, sticky="w")
self.blocknet_data_path_entry.grid(row=x + 1, column=y + 1, padx=(0, 10), pady=5, sticky="ew")
self.blocknet_custom_path_button.grid(row=x + 1, column=y + 3, padx=2, pady=2, sticky="e")
self.blocknet_download_bootstrap_button.grid(row=x, column=y + 3, padx=2, pady=2, sticky="e")
self.blocknet_data_path_status_checkbox.grid(row=x + 2, column=y, padx=10, pady=5, sticky=check_boxes_sticky)
self.blocknet_process_status_checkbox.grid(row=x + 3, column=y, padx=10, pady=5, sticky=check_boxes_sticky)
self.blocknet_conf_status_checkbox.grid(row=x + 2, column=y + 1, padx=10, pady=5, sticky=check_boxes_sticky)
self.blocknet_rpc_connection_checkbox.grid(row=x + 3, column=y + 1, padx=10, pady=5, sticky=check_boxes_sticky)
def grid_blockdx_frame(self, x, y, check_boxes_sticky):
# block-dx
self.blockdx_label.grid(row=x, column=y, columnspan=3, padx=5, pady=0)
self.blockdx_process_status_checkbox.grid(row=x + 1, column=y, padx=10, pady=5, sticky=check_boxes_sticky)
self.blockdx_valid_config_checkbox.grid(row=x + 1, column=y + 1, padx=10, pady=5, sticky=check_boxes_sticky)
def grid_xlite_frame(self, x, y, check_boxes_sticky):
# xlite
self.xlite_label.grid(row=x, column=y, columnspan=2, padx=5, pady=0)
self.xlite_process_status_checkbox.grid(row=x + 1, column=y, padx=10, pady=5, sticky=check_boxes_sticky)
self.xlite_daemon_process_status_checkbox.grid(row=x + 2, column=y, padx=10, pady=5, sticky=check_boxes_sticky)
self.xlite_valid_config_checkbox.grid(row=x + 1, column=y + 1, padx=10, pady=5, sticky=check_boxes_sticky)
self.xlite_daemon_valid_config_checkbox.grid(row=x + 2, column=y + 1, padx=10, pady=5,
sticky=check_boxes_sticky)
self.xlite_store_password_button.grid(row=x, column=y + 3, padx=2, pady=2, sticky="e")
def handle_signal(self, signum, frame):
print("Signal {} received.".format(signum))
self.on_close()
def on_close(self):
logging.info("Closing application...")
terminate_all_threads()
logging.info("Threads terminated.")
os._exit(0)
# self.destroy()
# exit()
#
# logging.info("Tkinter GUI destroyed.")
# Schedule forced exit after a 5-second timeout
# Timer(interval=0.25, function=os._exit, args=(0,)).start()
def adjust_theme(self):
if self.cfg and 'theme' in self.cfg:
actual = ctk.get_appearance_mode()
if self.cfg['theme'] != actual:
if actual == "Dark":
new_theme = "Light"
else:
new_theme = "Dark"
ctk.set_appearance_mode(new_theme)
def switch_theme_command(self):
actual = ctk.get_appearance_mode()
if actual == "Dark":
new_theme = "Light"
else:
new_theme = "Dark"
ctk.set_appearance_mode(new_theme)
save_cfg_json("theme", new_theme)
# print(actual, new_theme)
def xlite_store_password_button_mouse_click(self, event=None):
# Function to handle storing password
# Check if the right mouse button was clicked
if event and event.num == 3:
# wipe_stored_password
logging.info("Right click detected")
# Prevent the right-click event from propagating further
remove_cfg_json_key("salt")
remove_cfg_json_key("xl_pass")
self.xlite_password = None
# Delete CC_WALLET_PASS variable
if "CC_WALLET_PASS" in os.environ:
os.environ.pop("CC_WALLET_PASS")
# Delete CC_WALLET_AUTOLOGIN variable
if "CC_WALLET_AUTOLOGIN" in os.environ:
os.environ.pop("CC_WALLET_AUTOLOGIN")
# self.xlite_store_password_button.configure(relief='raised')
return "break"
# For left-click event
if event and event.num == 1:
# ask_user_pass
# store_salted_pass
logging.info("Left click detected")
fg_color = self.xlite_frame.cget('fg_color')
password = ctkInputDialogMod.CTkInputDialog(
title="Store XLite Password",
text="Enter XLite password:",
show='*',
fg_color=fg_color).get_input()
# password = simpledialog.askstring("Store XLite Password","Enter XLite password:" , show='*')
if password:
encryption_key = generate_key()
salted_pass = encrypt_password(password, encryption_key)
save_cfg_json(key="salt", data=encryption_key.decode())
save_cfg_json(key="xl_pass", data=salted_pass)
# Store the password in a variable or perform other actions
# logging.debug(f"Password entered: {password}, salted xl_pass: {salted_pass}")
self.xlite_password = password
else:
logging.info("No password entered.")
# Perform actions for left-click (if needed)
return "break"
def refresh_xlite_confs(self):
self.xlite_utility.parse_xlite_conf()
self.xlite_utility.parse_xlite_daemon_conf()
def blocknet_check_config(self):
use_xlite = bool(self.xlite_utility.xlite_daemon_confs_local)
if use_xlite:
xlite_daemon_conf = self.xlite_utility.xlite_daemon_confs_local
else:
xlite_daemon_conf = None
self.blocknet_utility.compare_and_update_local_conf(xlite_daemon_conf)
def blockdx_check_config(self):
# Get required data
if bool(self.blocknet_utility.data_folder and self.blocknet_utility.blocknet_conf_local):
xbridgeconfpath = os.path.normpath(os.path.join(self.blocknet_utility.data_folder, "xbridge.conf"))
logging.info(f"xbridgeconfpath: {xbridgeconfpath}")
rpc_user = self.blocknet_utility.blocknet_conf_local.get('global', {}).get('rpcuser')
rpc_password = self.blocknet_utility.blocknet_conf_local.get('global', {}).get('rpcpassword')
self.blockdx_utility.compare_and_update_local_conf(xbridgeconfpath, rpc_user, rpc_password)
def open_custom_path_dialog(self):
# ctk.filedialog.askdirectory()
custom_path = ctk.filedialog.askdirectory(parent=self, title="Select Custom Path for Blocknet Core Datadir",
mustexist=False)
if custom_path:
self.on_custom_path_set(custom_path)
def on_custom_path_set(self, custom_path):
self.blocknet_utility.set_custom_data_path(custom_path)
self.blocknet_data_path_entry_string_var.set(self.blocknet_utility.data_folder)
save_cfg_json('custom_path', custom_path)
def enable_blocknet_start_button(self):
self.disable_start_blocknet_button = False
def enable_blockdx_start_button(self):
self.disable_start_blockdx_button = False
def enable_xlite_start_button(self):
self.disable_start_xlite_button = False
def download_bootstrap_command(self):
disable_button(self.blocknet_download_bootstrap_button, img=self.install_greyed_img)
self.bootstrap_thread = Thread(target=self.blocknet_utility.download_bootstrap, daemon=True)
self.bootstrap_thread.start()
def install_delete_blocknet_command(self):
blocknet_boolvar = self.blocknet_bin_installed_boolvar.get()
if blocknet_boolvar:
self.delete_blocknet_command()
else:
self.download_blocknet_command()
def install_delete_blockdx_command(self):
blockdx_boolvar = self.blockdx_bin_installed_boolvar.get()
if blockdx_boolvar:
self.delete_blockdx_command()
else:
self.download_blockdx_command()
def install_delete_xlite_command(self):
xlite_boolvar = self.xlite_bin_installed_boolvar.get()
if xlite_boolvar:
self.delete_xlite_command()
else:
self.download_xlite_command()
def download_blocknet_command(self):
disable_button(self.bins_install_delete_blocknet_button, img=self.install_greyed_img)
self.download_blocknet_thread = Thread(target=self.blocknet_utility.download_blocknet_bin, daemon=True)
self.download_blocknet_thread.start()
def download_blockdx_command(self):
disable_button(self.bins_install_delete_blockdx_button, img=self.install_greyed_img)
self.download_blockdx_thread = Thread(target=self.blockdx_utility.download_blockdx_bin, daemon=True)
self.download_blockdx_thread.start()
def download_xlite_command(self):
disable_button(self.bins_install_delete_xlite_button, img=self.install_greyed_img)
self.download_xlite_thread = Thread(target=self.xlite_utility.download_xlite_bin, daemon=True)
self.download_xlite_thread.start()
def delete_blocknet_command(self):
blocknet_pruned_version = self.blocknet_version[0].replace('v', '')
for item in os.listdir(aio_folder):
item_path = os.path.join(aio_folder, item)
if os.path.isdir(item_path):
# if a wrong version is found, delete it.
if 'blocknet-' in item:
if blocknet_pruned_version in item:
logging.info(f"deleting {item_path}")
shutil.rmtree(item_path)
def delete_blockdx_command(self):
blockdx_pruned_version = self.blockdx_version[0].replace('v', '')
for item in os.listdir(aio_folder):
item_path = os.path.join(aio_folder, item)
if system == 'Darwin':
blockdx_filename = os.path.basename(blockdx_release_url)
if os.path.isfile(item_path):
if blockdx_filename in item_path:
self.blockdx_utility.unmount_dmg()
os.remove(item_path)
else:
if os.path.isdir(item_path):
if 'BLOCK-DX-' in item:
if blockdx_pruned_version in item:
logging.info(f"deleting {item_path}")
shutil.rmtree(item_path)
def delete_xlite_command(self):
xlite_pruned_version = self.xlite_version[0].replace('v', '')
for item in os.listdir(aio_folder):
item_path = os.path.join(aio_folder, item)
if system == 'Darwin':
xlite_filename = os.path.basename(xlite_release_url)
if os.path.isfile(item_path):
if xlite_filename in item_path:
self.xlite_utility.unmount_dmg()
os.remove(item_path)
else:
if os.path.isdir(item_path):
if 'XLite-' in item:
if xlite_pruned_version in item:
logging.info(f"deleting {item_path}")
shutil.rmtree(item_path)
def start_or_close_blocknet(self):
img = self.stop_greyed_img if self.blocknet_process_running else self.start_greyed_img
disable_button(self.blocknet_start_close_button, img=img)
self.disable_start_blocknet_button = True
if self.blocknet_process_running:
self.blocknet_t1 = Thread(target=self.blocknet_utility.close_blocknet)
self.blocknet_t1.start()
else:
self.blocknet_check_config()
self.blocknet_t2 = Thread(target=self.blocknet_utility.start_blocknet)
self.blocknet_t2.start()
self.after(self.time_disable_button, self.enable_blocknet_start_button)
def start_or_close_blockdx(self):
img = self.stop_greyed_img if self.blockdx_process_running else self.start_greyed_img
disable_button(self.blockdx_start_close_button, img=img)
self.disable_start_blockdx_button = True
if self.blockdx_process_running:
self.blockdx_t1 = Thread(target=self.blockdx_utility.close_blockdx)
self.blockdx_t1.start()
else:
self.blockdx_check_config()
self.blockdx_t2 = Thread(target=self.blockdx_utility.start_blockdx)
self.blockdx_t2.start()
self.after(self.time_disable_button, self.enable_blockdx_start_button)
def start_or_close_xlite(self):
img = self.stop_greyed_img if self.xlite_process_running else self.start_greyed_img
disable_button(self.xlite_start_close_button, img=img)
self.disable_start_xlite_button = True
if self.xlite_process_running:
self.xlite_t1 = Thread(target=self.xlite_utility.close_xlite)
self.xlite_t1.start()
else:
disable_button(self.xlite_start_close_button, img=self.start_greyed_img)
if self.xlite_password:
env_vars = [{"CC_WALLET_PASS": self.xlite_password}, {"CC_WALLET_AUTOLOGIN": 'true'}]
else:
env_vars = []
self.xlite_t2 = Thread(target=lambda: self.xlite_utility.start_xlite(env_vars=env_vars))
self.xlite_t2.start()
self.after(self.time_disable_button, self.enable_xlite_start_button)
def update_blocknet_bootstrap_button(self):
bootstrap_download_in_progress = bool(self.blocknet_utility.bootstrap_checking)
enabled = (self.blocknet_utility.data_folder and not bootstrap_download_in_progress and
not self.blocknet_process_running)
if enabled:
enable_button(self.blocknet_download_bootstrap_button, img=self.install_img)
else:
disable_button(self.blocknet_download_bootstrap_button, img=self.install_greyed_img)
if bootstrap_download_in_progress:
if self.blocknet_utility.bootstrap_percent_download:
var = f"{self.blocknet_utility.bootstrap_percent_download:.1f}%"
elif self.blocknet_utility.bootstrap_extracting:
var = "Unpacking"
else:
var = "Loading"
else:
var = "Bootstrap"
self.blocknet_download_bootstrap_string_var.set(var)
def update_blocknet_start_close_button(self):
# blocknet_start_close_button
# blocknet_start_close_button_string_var
var = close_string if self.blocknet_process_running else start_string
self.blocknet_start_close_button_string_var.set(var)
if self.blocknet_process_running:
configure_tooltip_text(self.blocknet_start_close_button_tooltip, close_string)
else:
configure_tooltip_text(self.blocknet_start_close_button_tooltip, start_string)
enabled = (not self.blocknet_utility.downloading_bin and
not self.disable_start_blocknet_button and
not self.blocknet_utility.bootstrap_checking)
# logging.debug(
# f"blocknet_utility.downloading_bin: {self.blocknet_utility.downloading_bin}"
# f", self.disable_start_blocknet_button: {self.disable_start_blocknet_button}, enabled: {enabled}"
# )
if enabled:
img = self.stop_img if self.blocknet_process_running else self.start_img
enable_button(self.blocknet_start_close_button, img=img)
else: