-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailFlow.py
More file actions
1800 lines (1523 loc) · 55.1 KB
/
Copy pathEmailFlow.py
File metadata and controls
1800 lines (1523 loc) · 55.1 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
"""
EmailFlow - GUI Application Main File
-------------------------------------
This is the core GUI file built using CustomTkinter.
It handles:
- The full user interface layout and components
- Theme customization and preferences
- DPI settings and visual toggles
- Email configuration (sender, receiver, subject)
- File selection and conversion UI
- Integration with the logic layer (advmail.py)
Designed for simplicity, speed, and user customization.
For more detail visit https://github.com/Utkarsh-X/EmailFlow
"""
# === Standard Library ===
import os
import sys
import json
import threading
import warnings
import webbrowser
from datetime import date
# === Tkinter & GUI Libraries ===
import tkinter as tk
from tkinter import colorchooser, filedialog
import customtkinter
import CTkMessagebox
from PIL import Image, ImageTk
# === Local Application Modules ===
import advmail
from version import __version__
print(f"Version: {__version__}")
# Dynamically get the path to data.json for .py and .exe
def get_data_path():
if getattr(sys, "frozen", False):
base_path = os.path.dirname(sys.executable)
else:
base_path = os.path.abspath(".")
return os.path.join(base_path, "data.json")
# Load default values into globals
def var_load():
global mode, var4dpi, v2, v3, primary_color, secondary_color, menu_color, hover_color
global switch_v_pass1, list1, switch_v_date1, switch_v_sub1, switch_v_img1, switch_v_del1
global addre1, recname1
mode = "light" # default mode if no settings exist
var4dpi = "300"
v2 = ""
v3 = ""
primary_color = ""
secondary_color = ""
menu_color = ""
hover_color = ""
switch_v_pass1 = "off"
list1 = [""]
switch_v_date1 = "on"
switch_v_sub1 = "on"
switch_v_img1 = "off"
switch_v_del1 = "on"
addre1 = ""
recname1 = ""
def encrypt(text: str, shift: int = 3) -> str:
"""Encrypt the text by shifting characters forward."""
encrypted = ""
for char in text:
encrypted += chr((ord(char) + shift) % 256) # wrap around byte range
return encrypted
def decrypt(text: str, shift: int = 3) -> str:
"""Decrypt the text by shifting characters backward."""
decrypted = ""
for char in text:
decrypted += chr((ord(char) - shift) % 256)
return decrypted
# Load variable values from data.json
def load_variables():
filename = get_data_path()
global mode, var4dpi, v2, v3, primary_color, secondary_color, menu_color, hover_color
global switch_v_pass1, list1, switch_v_date1, switch_v_sub1, switch_v_img1, switch_v_del1
global addre1, recname1
try:
with open(filename, "r") as file:
data = json.load(file)
mode = data.get("mode", mode)
# Apply the loaded theme mode
customtkinter.set_appearance_mode(mode)
var4dpi = data.get("var4dpi", var4dpi)
v2 = data.get("v2", v2)
v3 = data.get("v3", v3)
primary_color = data.get("primary_color", primary_color)
secondary_color = data.get("secondary_color", secondary_color)
menu_color = data.get("menu_color", menu_color)
hover_color = data.get("hover_color", hover_color)
switch_v_pass1 = data.get("switch_v_pass1", switch_v_pass1)
list1 = data.get("list1", list1)
switch_v_date1 = data.get("switch_v_date1", switch_v_date1)
switch_v_sub1 = data.get("switch_v_sub1", switch_v_sub1)
switch_v_img1 = data.get("switch_v_img1", switch_v_img1)
switch_v_del1 = data.get("switch_v_del1", switch_v_del1)
addre1 = data.get("addre1", addre1)
recname1 = data.get("recname1", recname1)
# Only decrypt v2 if it has a value
if v2:
v2 = decrypt(v2, shift=5)
except FileNotFoundError:
print(f"{filename} not found. Using default values.")
except json.JSONDecodeError:
print(f"Error decoding JSON from {filename}. Using default values.")
var_load() # First set defaults
load_variables() # Load saved settings from data.json
# Update specific global variables from a dictionary
def update_variables(updates):
global mode, var4dpi, v2, v3, primary_color, secondary_color, menu_color, hover_color
global switch_v_pass1, list1, switch_v_date1, switch_v_sub1, switch_v_img1, switch_v_del1
global addre1, recname1
if "mode" in updates:
mode = updates["mode"]
if "var4dpi" in updates:
var4dpi = updates["var4dpi"]
if "v2" in updates:
v2 = updates["v2"]
if "v3" in updates:
v3 = updates["v3"]
if "primary_color" in updates:
primary_color = updates["primary_color"]
if "secondary_color" in updates:
secondary_color = updates["secondary_color"]
if "menu_color" in updates:
menu_color = updates["menu_color"]
if "hover_color" in updates:
hover_color = updates["hover_color"]
if "switch_v_pass1" in updates:
switch_v_pass1 = updates["switch_v_pass1"]
if "list1" in updates:
list1 = updates["list1"]
if "switch_v_date1" in updates:
switch_v_date1 = updates["switch_v_date1"]
if "switch_v_sub1" in updates:
switch_v_sub1 = updates["switch_v_sub1"]
if "switch_v_img1" in updates:
switch_v_img1 = updates["switch_v_img1"]
if "switch_v_del1" in updates:
switch_v_del1 = updates["switch_v_del1"]
if "addre1" in updates:
addre1 = updates["addre1"]
if "recname1" in updates:
recname1 = updates["recname1"]
# Convert current state to dictionary
def data_to_save():
# Handle StringVar objects by getting their values
global switch_v_del1
try:
del1_value = (
switch_v_del1.get() if hasattr(switch_v_del1, "get") else switch_v_del1
)
except:
del1_value = "on" # Default value if there's an error
# Encrypt password before saving
encrypted_password = encrypt(v2, shift=5) if v2 else ""
return {
"mode": mode,
"var4dpi": var4dpi,
"v2": encrypted_password,
"v3": v3,
"primary_color": primary_color,
"secondary_color": secondary_color,
"menu_color": menu_color,
"hover_color": hover_color,
"switch_v_pass1": switch_v_pass1,
"list1": list1,
"switch_v_date1": switch_v_date1,
"switch_v_sub1": switch_v_sub1,
"switch_v_img1": switch_v_img1,
"switch_v_del1": del1_value,
"addre1": addre1,
"recname1": recname1,
}
# Save data to data.json
def save_variables():
filename = get_data_path()
with open(filename, "w") as file:
json.dump(data_to_save(), file, indent=4)
def resource_path(relative_path: str) -> str:
try:
base_path = sys._MEIPASS # PyInstaller bundles files here at runtime
except AttributeError:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
# Theme and color settings will be applied after loading from data.json
customtkinter.set_default_color_theme("green")
root = customtkinter.CTk()
root.minsize(500, 500)
app_width = 1130
app_height = 690
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width / 2) - (app_width / 2)
y = (screen_height / 2) - (app_height / 1.85)
root.geometry(f"{app_width}x{app_height}+{int(x)}+{int(y)}")
root.title("EmailFlow Manager")
root.resizable(False, False)
root.iconbitmap(resource_path(os.path.join("assets", "emailB.ico")))
def apply1():
global var4dpi
try:
# Validate input
if entrybox20.get() == "":
var4dpi = "300"
entrybox20.insert(0, var4dpi)
return
# Attempt to convert input to integer
var4dpi = int(entrybox20.get())
# Validate DPI range
if var4dpi < 10 or var4dpi > 1000:
raise ValueError(
"DPI must be between 10 and 1000.\n Or set default DPI 200"
)
# Update and save variables
update_variables({"var4dpi": var4dpi})
save_variables()
except ValueError as e:
CTkMessagebox.CTkMessagebox(title="Error", message=str(e), option_1="Ok")
var4dpi = "300" # Reset to default on error
def choose_color_button():
global primary_color
color_code = colorchooser.askcolor(title="Choose color")[1]
if color_code:
primary_color = color_code
update_variables(primary_color)
save_variables()
choose_color_button_load(primary_color)
def choose_color_button_load(primary_color):
# List of permanent widgets that should be styled
widgets = [
menu_button,
bs1,
menu_button_p1,
menu_button_p2,
menu_button1,
menu_item1,
menu_item2,
menu_item3,
del_userbutton,
add_userbutton,
b2,
b3,
b4,
b5,
]
# Configure permanent widgets
for widget in widgets:
widget.configure(fg_color=primary_color)
segmented_button.configure(selected_color=primary_color)
# Configure switches
switches = [switch1, switch2, switch3, switch4, switch6]
for switch in switches:
switch.configure(progress_color=primary_color)
def choose_color_button16():
global secondary_color
color_code1 = colorchooser.askcolor(title="Choose color")[1]
if color_code1:
secondary_color = color_code1
update_variables(secondary_color)
save_variables()
choose_color_button16_load(secondary_color)
def choose_color_button16_load(secondary_color):
global widgets1
widgets1 = [b6, b7, b65]
for widget in widgets1:
widget.configure(fg_color=secondary_color)
def choose_color_menu15():
global menu_color
color_code2 = colorchooser.askcolor(title="Choose color")[1]
if color_code2:
menu_color = color_code2
update_variables(menu_color)
save_variables()
choose_color_menu15_load(menu_color)
def choose_color_menu15_load(menu_color):
menu_frame.configure(fg_color=menu_color)
def choose_color_hover():
global hover_color
color_code1 = colorchooser.askcolor(title="Choose color")[1]
if color_code1:
hover_color = color_code1
update_variables(hover_color)
save_variables()
choose_color_hover_load(hover_color)
def choose_color_hover_load(hover_color):
segmented_button.configure(selected_hover_color=hover_color)
# List of permanent widgets that should receive hover color
widgets = [
b6,
b7,
bs1,
b65,
menu_button,
menu_button1,
menu_button_p1,
menu_button_p2,
menu_item1,
menu_item2,
menu_item3,
del_userbutton,
add_userbutton,
b2,
b3,
b4,
b5,
theme1,
theme15,
theme16,
theme2,
]
# Configure hover color for permanent widgets
for widget in widgets:
widget.configure(hover_color=hover_color)
def default_color():
global primary_color, secondary_color, menu_color, hover_color
if not any([primary_color, secondary_color, menu_color, hover_color]):
return
primary_color = ""
secondary_color = ""
menu_color = ""
hover_color = ""
update_variables(
{
"primary_color": primary_color,
"secondary_color": secondary_color,
"menu_color": menu_color,
"hover_color": hover_color,
}
)
save_variables()
CTkMessagebox.CTkMessagebox(
title="Reload Needed!",
message="Please reload the application to see changes.\n",
option_1="Ok",
)
def toggle_menu1():
apply1()
if menu_frame.winfo_ismapped():
menu_frame.place_forget() # Hide the menu frame if it is currently visible
menu_frame2.pack_forget()
else:
menu_frame.place(
x=0, y=0
) # Place the menu frame at the top left corner of the window
menu_frame.lift() # Raise the menu frame to the top of the stacking order # Placing the button at the top left corner of the window
menu_frame2.pack_forget()
def toggle_menu():
if menu_frame.winfo_ismapped():
menu_frame.place_forget() # Hide the menu frame if it is currently visible
menu_frame2.pack_forget()
else:
menu_frame.place(
x=0, y=0
) # Place the menu frame at the top left corner of the window
menu_frame.lift() # Raise the menu frame to the top of the stacking order # Placing the button at the top left corner of the window
menu_frame2.pack_forget()
def off_menu():
menu_frame.place_forget()
def clc_click(event):
if int(event.x) > 190:
menu_frame.place_forget()
root.bind("<Button-1>", clc_click)
def changetheme():
global mode
if mode == "dark":
customtkinter.set_appearance_mode("light")
mode = "light"
b5.configure(image=imaphoto2)
root.iconbitmap(resource_path(os.path.join("assets", "emailB.ico")))
link_label.configure(text_color="blue")
else:
customtkinter.set_appearance_mode("dark")
mode = "dark"
b5.configure(image=imaphoto1)
root.iconbitmap(resource_path(os.path.join("assets", "emailL.ico")))
link_label.configure(text_color="lightblue")
def open1():
if frame91.winfo_ismapped():
frame91.place_forget() # Hide the menu frame if it is currently visible
menu_item3.configure(text="About Me")
if frame9.winfo_ismapped():
frame9.place_forget() # Hide the menu frame if it is currently visible
menu_item2.configure(text="Setting")
menu_frame.place_forget()
else:
frame9.place(x=0, y=0) # Place the menu frame to cover the entire root frame
frame9.lift()
menu_frame.lift()
menu_item2.configure(text="Home")
b5.lift()
menu_frame.place_forget()
def open2():
if frame9.winfo_ismapped():
frame9.place_forget() # Hide the menu frame if it is currently visible
menu_item2.configure(text="Setting")
if frame91.winfo_ismapped():
frame91.place_forget() # Hide the menu frame if it is currently visible
menu_item3.configure(text="About Me")
else:
frame91.place(x=0, y=0) # Place the menu frame to cover the entire root frame
frame91.lift()
menu_frame.lift()
menu_item3.configure(text="Home")
b5.lift()
menu_frame.place_forget()
def copytempo():
source_folder = advmail.create_folder()
destination_folder = advmail.select_folder()
if not os.path.isdir(destination_folder):
return
advmail.copy_files(source_folder, destination_folder)
def ne():
if menu_frame2.winfo_ismapped(): # Check if menu_frame2 is currently visible
menu_frame2.pack_forget() # Hide the menu frame if it is currently visible
else:
menu_frame2.pack() # Show the menu frame
menu_frame2.lift() # Bring the menu frame to the front
def getcombo(choice):
global ref_receiver
ref_receiver = choice
warnings.simplefilter("ignore", category=DeprecationWarning)
imaphoto1 = ImageTk.PhotoImage(
Image.open(resource_path(os.path.join("assets", "clicktolight.png"))).resize(
(21, 21), Image.Resampling.LANCZOS
)
)
imaphoto2 = ImageTk.PhotoImage(
Image.open(resource_path(os.path.join("assets", "clicktodark.png"))).resize(
(21, 21), Image.Resampling.LANCZOS
)
)
# Initialize appearance based on current mode
customtkinter.set_appearance_mode(mode)
# Filter out Deprecation Warning and UserWarning
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=UserWarning)
frame9 = customtkinter.CTkFrame(root, width=app_width, height=app_height)
frame91 = customtkinter.CTkFrame(root, width=app_width, height=app_height)
label20 = customtkinter.CTkLabel(frame9, text="Settings", font=("Bahnschrift", 40))
label20.place(x=160, y=3)
menu_button_p1 = customtkinter.CTkButton(
frame9, font=("bold", 20), text="☰", command=toggle_menu1, width=50, height=10
)
menu_button_p1.place(x=10, y=10)
menu_button_p2 = customtkinter.CTkButton(
frame91, font=("bold", 20), text="☰", command=toggle_menu, width=50, height=10
)
menu_button_p2.place(x=10, y=10)
label1 = customtkinter.CTkLabel(
frame91, text="About the software", font=("Bahnschrift", 40)
)
label1.place(x=160, y=3)
def open_link(event):
webbrowser.open("https://github.com/Utkarsh-X/EmailFlow")
main_text = (
"Welcome to my open-source project! I'm excited to introduce a powerful tool designed to simplify your \nemail and file management tasks.\n\n"
"This application seamlessly integrates core features—sending emails, converting PDFs to high-resolution \nimages (with DPI control), and managing multiple files at once.\n\n"
"With a simple interface, you can automate the entire process: select recipients, set a subject line \n(optionally using today’s date), and choose whether to convert or attach files.\n\n"
"The app remembers your preferences, making repeated tasks effortless.\n\n"
"To enhance your user experience, the application remembers your settings and preferences, streamlining \nfuture interactions and making it easier for you to send emails without having to reconfigure each time.\n\n"
"Whether you're a professional or a student, this tool adapts to your needs with speed and ease.\n\n"
"Have suggestions or feedback? Feel free to contribute on"
)
inframe91 = customtkinter.CTkFrame(frame91, width=917, height=550, border_width=3)
inframe91.place(x=120, y=90)
# Create a label for the main text
para = customtkinter.CTkLabel(
inframe91,
text=main_text,
wraplength=850,
font=("Roboto", 17),
justify="left",
anchor="w",
)
para.place(x=40, y=30)
link_label = customtkinter.CTkLabel(
inframe91,
text="https://github.com/Utkarsh-X/EmailFlow",
text_color="blue",
fg_color=None,
font=("Roboto", 17, "underline"),
)
if mode == "dark":
link_label.configure(text_color="lightblue")
link_label.place(x=476 + para.winfo_width(), y=346)
dev_label = customtkinter.CTkLabel(
inframe91, text="Developed by Utkarsh-X", fg_color=None, font=("Roboto", 17)
)
dev_label.place(x=715 + para.winfo_width(), y=498)
link_dot = customtkinter.CTkLabel(
inframe91, text=".", fg_color=None, font=("Roboto", 17)
)
link_dot.place(x=789 + para.winfo_width(), y=346)
# Bind the click event to open the link
link_label.bind("<Button-1>", open_link)
# Change cursor to pointer when hovering over the link label
link_label.bind("<Enter>", lambda e: link_label.configure(cursor="hand2"))
link_label.bind("<Leave>", lambda e: link_label.configure(cursor=""))
ver_dev_detail = customtkinter.CTkLabel(
inframe91,
text=f" Version {__version__}",
fg_color=None,
font=("Roboto", 17),
)
ver_dev_detail.place(x=716 + para.winfo_width(), y=475)
frame10 = customtkinter.CTkFrame(frame9, width=700, height=400)
frame10.place(x=40, y=90)
frame11 = customtkinter.CTkFrame(frame10)
frame11.pack(pady=(15, 10), padx=20, side="left" and "top")
label20_main = customtkinter.CTkLabel(
frame11,
text="Set DPI for generated images:",
justify="left",
font=("Bahnschrift", 18),
)
label20_main.grid(row=0, column=0, sticky="w", padx=10, pady=(10, 0))
label20_sub = customtkinter.CTkLabel(
frame11, text="Default DPI is set to 300.", justify="left", font=("Bahnschrift", 14)
)
label20_sub.grid(row=1, column=0, sticky="nw", padx=10, pady=(0, 10))
entrybox20 = customtkinter.CTkEntry(
frame11,
width=150,
placeholder_text="Set DPI",
font=("Bahnschrift", 18),
corner_radius=5,
justify="center",
)
entrybox20.grid(row=0, column=1, rowspan=2, padx=(0, 40), pady=(10, 40))
frame11.columnconfigure(0, weight=1) # Make the first column expandable
frame11.pack(fill="x") # Make the frame expand horizontally
frame14 = customtkinter.CTkFrame(frame10)
frame14.pack(pady=10, padx=20, side="top")
frame14.columnconfigure(0, weight=1) # Make the first column expandable
frame14.pack(fill="x") # Make the frame expand horizontally
frame16 = customtkinter.CTkFrame(frame10)
frame16.pack(pady=(10, 15), padx=20, side="top")
frame16.columnconfigure(0, weight=1) # Make the first column expandable
frame16.pack(fill="x")
def reset_app_settings():
global var4dpi, v2, v3, primary_color, secondary_color, menu_color, hover_color, switch_v_pass1, list1, switch_v_date1, switch_v_sub1, switch_v_img1, switch_v_del1, addre1, recname1
var_load()
for var in [
v2,
v3,
primary_color,
secondary_color,
menu_color,
hover_color,
switch_v_pass1,
switch_v_date1,
switch_v_img1,
switch_v_del1,
list1,
addre1,
recname1,
]:
update_variables(var)
save_variables()
combox1.set("")
combox1.configure(values=[""])
entrybox2.delete(0, "end")
fname = "data.json"
current_directory = os.getcwd()
fs = os.path.join(current_directory, fname)
if os.path.exists(fs):
os.remove(fs)
print(f"{fname} file cleared at address {fs}")
else:
print("Error deleting the file") # with open(fname,'w') as file:
# file.write('{}')
CTkMessagebox.CTkMessagebox(
title="System",
message="The application has been reset successfully.\nPlease restart the application to see the changes.",
option_1="Ok",
)
bs1 = customtkinter.CTkButton(
frame16,
width=70,
height=30,
font=("Bahnschrift", 16),
text="Reset Application",
corner_radius=5,
command=reset_app_settings,
border_width=2,
)
bs1.pack(padx=(20, 20), pady=(10, 10), anchor="sw") # for southeast corner
b5 = customtkinter.CTkButton(
root,
width=45,
height=10,
image=imaphoto1,
text="",
corner_radius=5,
command=changetheme,
border_width=2,
)
b5.pack(side="top", padx=(90, 10), pady=(10, 15), anchor="nw")
label2 = customtkinter.CTkLabel(root, text="EmailFlow", font=("Bahnschrift", 40))
label2.place(x=160, y=3)
# Create a button to toggle the menu
menu_button = customtkinter.CTkButton(
root, font=("bold", 20), text="☰", command=toggle_menu, width=50, height=10
)
menu_button.place(x=10, y=10)
menu_frame = customtkinter.CTkFrame(root)
# Add menu items to the frame
menu_button1 = customtkinter.CTkButton(
menu_frame, font=("bold", 20), text="☰", command=toggle_menu, width=50, height=30
)
menu_button1.place(x=10, y=10)
menu_button1.pack(side="left" and "top", pady=10, padx=10, anchor="w")
menu_frame2_visible = False # Variable to track the visibility state of menu_frame2
menu_frame2 = customtkinter.CTkFrame(menu_frame)
menu_item2 = customtkinter.CTkButton(
menu_frame, font=("Bahnschrift", 18), anchor="w", command=open1, text="Setting"
)
menu_item2.configure(width=150, height=35)
menu_item2.pack(pady=10, padx=(10, 30))
menu_item1 = customtkinter.CTkButton(
menu_frame, command=ne, anchor="w", font=("Bahnschrift", 18), text="Change Theme"
)
menu_item1.configure(width=150, height=35)
menu_item1.pack(pady=10, padx=(10, 30))
theme1 = customtkinter.CTkButton(
menu_frame2,
anchor="w",
font=("Bahnschrift", 16),
text="Primary Color ",
command=choose_color_button,
corner_radius=10,
fg_color="black",
)
theme1.configure(width=150, height=35)
theme1.pack(pady=10, padx=(10, 30))
theme16 = customtkinter.CTkButton(
menu_frame2,
anchor="w",
font=("Bahnschrift", 16),
text="Secondary Color",
command=choose_color_button16,
corner_radius=10,
fg_color="black",
)
theme16.configure(width=150, height=35)
theme16.pack(pady=10, padx=(10, 30))
theme15 = customtkinter.CTkButton(
menu_frame2,
anchor="w",
font=("Bahnschrift", 16),
text="Menu Color",
command=choose_color_menu15,
corner_radius=10,
fg_color="black",
)
theme15.configure(width=150, height=35)
theme15.pack(pady=10, padx=(10, 30))
theme2 = customtkinter.CTkButton(
menu_frame2,
anchor="w",
font=("Bahnschrift", 16),
text="Hover Color",
command=choose_color_hover,
corner_radius=10,
fg_color="black",
)
theme2.configure(width=150, height=35)
theme2.pack(pady=10, padx=(10, 30))
themedefault = customtkinter.CTkButton(
menu_frame2,
anchor="w",
font=("Bahnschrift", 16),
text="Default Color",
command=default_color,
corner_radius=10,
fg_color="black",
)
themedefault.configure(width=150, height=35)
themedefault.pack(pady=10, padx=(10, 30))
menu_item3 = customtkinter.CTkButton(
menu_frame, anchor="w", font=("Bahnschrift", 18), text="About Me", command=open2
)
menu_item3.configure(width=150, height=35)
menu_item3.pack(side="bottom", pady=(10, 1000), padx=(10, 30))
frame = customtkinter.CTkFrame(root)
frame.pack(side="top", anchor="nw", padx=20, pady=20)
label3 = customtkinter.CTkLabel(
frame, text="Select The Email Reciever:", font=("Bahnschrift", 24)
)
label3.pack(pady=0, padx=10, anchor="w")
combox1 = customtkinter.CTkComboBox(
frame,
values=list1,
height=25,
width=363,
font=("Bahnschrift", 20),
dropdown_font=("Bahnschrift", 20),
justify="center",
command=getcombo,
dropdown_hover_color="black",
)
combox1.pack(side="left", padx=10)
def input():
global dialog, list1, primary_color, hover_color
# Handle all possible color combinations
if primary_color and hover_color:
dialog = customtkinter.CTkInputDialog(
title="Add New Email",
text="Enter the Email Below",
button_fg_color=primary_color,
button_hover_color=hover_color,
)
elif primary_color:
dialog = customtkinter.CTkInputDialog(
title="Add New Email",
text="Enter the Email Below",
button_fg_color=primary_color,
)
elif hover_color:
dialog = customtkinter.CTkInputDialog(
title="Add New Email",
text="Enter the Email Below",
button_hover_color=hover_color,
)
else:
dialog = customtkinter.CTkInputDialog(
title="Add New Email", text="Enter the Email Below"
)
dialog.iconbitmap(resource_path(os.path.join("assets", "emailL.ico")))
val22 = dialog.get_input()
if val22 != "":
list1 = list1 + [val22]
update_variables(list1)
save_variables()
combox1.configure(values=list1)
def add_user():
input()
def del_user():
global list1
list2 = []
selected_value = combox1.get()
print(selected_value)
if selected_value != "":
list2 = [x for x in list1 if x != selected_value]
list1 = list2
update_variables(list1)
save_variables()
combox1.configure(values=list1)
combox1.set(list1[0])
del_userbutton = customtkinter.CTkButton(
frame,
text="Delete User",
command=del_user,
height=20,
width=35,
font=("Bahnschrift", 22),
text_color="black",
state="normal",
)
del_userbutton.pack(side="right", padx=(5, 30), pady=10, anchor="e")
add_userbutton = customtkinter.CTkButton(
frame,
text="Add User",
command=add_user,
height=20,
width=35,
font=("Bahnschrift", 22),
text_color="black",
state="normal",
)
add_userbutton.pack(side="right", padx=(20, 30), pady=10)
frame4 = customtkinter.CTkFrame(root)
frame4.pack(side="top", anchor="nw", padx=20, pady=10)
frame_b2 = customtkinter.CTkFrame(frame4)
frame_b2.pack(side="left", padx=10)
def input2():
global v2, dialog2, primary_color, hover_color
# Handle all possible color combinations
if primary_color and hover_color:
dialog2 = customtkinter.CTkInputDialog(
title="Enter Password",
text="Enter the Password Below",
button_fg_color=primary_color,
button_hover_color=hover_color,
)
elif primary_color:
dialog2 = customtkinter.CTkInputDialog(
title="Enter Password",
text="Enter the Password Below",
button_fg_color=primary_color,
)
elif hover_color:
dialog2 = customtkinter.CTkInputDialog(
title="Enter Password",
text="Enter the Password Below",
button_hover_color=hover_color,
)
else:
dialog2 = customtkinter.CTkInputDialog(
title="Enter Password", text="Enter the Password Below"
)
dialog2.iconbitmap(resource_path(os.path.join("assets", "emailL.ico")))
raw_password = dialog2.get_input()
v2 = raw_password
update_variables({"v2": raw_password})
save_variables()
# Update the text of the b2
ads = "*" * len(v2)
if v2 != "":
if switch_v_pass.get() == "on":
label_below_b2.configure(text=ads)
else:
label_below_b2.configure(text=v2)
if "v2" not in globals():
v2 = "Click Above to Enter Password"
b2 = customtkinter.CTkButton(
frame_b2,
text="Enter your Password",
height=20,
width=20,
corner_radius=5,
command=input2,
font=("Bahnschrift", 18),
text_color="black",
state="normal",
fg_color="#b3e0dc",
)
b2.pack(side="top", padx=10)
label_below_b2 = customtkinter.CTkLabel(frame_b2, text=v2, font=("Bahnschrift", 14))
label_below_b2.pack(side="top", padx=10)
def input3():
global v3, dialog3, primary_color, hover_color