-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main_Code
921 lines (825 loc) Β· 39 KB
/
Main_Code
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
#NotePad
from tkinter import *
from tkinter import font
from tkinter.messagebox import showinfo
from tkinter.filedialog import askopenfilename, asksaveasfilename
import os
from tkinter import font,colorchooser,filedialog,messagebox
import re
import pyttsx3
import tkinter as tk
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import PyPDF2
import docx
from docx import Document
import nltk
from nltk.corpus import words
import tempfile
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.oxml.ns import nsdecls
from docx.oxml import parse_xml
if os.path.isfile("C:\\UnityPad\\#\\Keys.txt"):
nltk.download("words")
fontStyle='Comic Sans'
fontSize='13'
boldOn=False
def printout(event=None):
file=tempfile.mktemp('.txt')
open(file,'w').write(my_text.get(1.0,END))
os.startfile(file,'print')
def find():
#funtionality
def find_words():
my_text.tag_remove('match',1.0,END)
start_pos='1.0'
word=findentryField.get()
if word:
while True: #I am a boy I am 16 yrs old
start_pos=my_text.search(word,start_pos,stopindex=END) #1.0
if not start_pos:
break
end_pos=f'{start_pos}+{len(word)}c' #1.0+1c
my_text.tag_add('match',start_pos,end_pos)
my_text.tag_config('match',foreground='red',background='yellow')
start_pos=end_pos
def replace_text():
word = findentryField.get()
replaceword=replaceentryField.get()
content=my_text.get(1.0,END)
new_content=content.replace(word,replaceword)
my_text.delete(1.0,END)
my_text.insert(1.0,new_content)
#GUI
root1=Toplevel()
root1.wm_iconbitmap("C:\\Users\\DELL\\Downloads\\default-icon.ico")
root1.title('Find')
root1.geometry('450x250+500+200')
root1.resizable(0,0)
labelFrame=LabelFrame(root1,text='Find/Replace')
labelFrame.pack(pady=50)
findLabel=Label(labelFrame,text='Find')
findLabel.grid(row=0,column=0,padx=5,pady=5)
findentryField=Entry(labelFrame)
findentryField.grid(row=0,column=1,padx=5,pady=5)
replaceLabel = Label(labelFrame, text='Replace')
replaceLabel.grid(row=1, column=0, padx=5, pady=5)
replaceentryField = Entry(labelFrame)
replaceentryField.grid(row=1, column=1, padx=5, pady=5)
findButton=Button(labelFrame,text='FIND',command=find_words)
findButton.grid(row=2,column=0,padx=5,pady=5)
replaceButton = Button(labelFrame, text='REPLACE',command=replace_text)
replaceButton.grid(row=2, column=1, padx=5, pady=5)
def doSomething():
my_text.tag_remove('match',1.0,END)
root1.destroy()
root1.protocol('WM_DELETE_WINDOW',doSomething)
root1.mainloop()
def statusBarFunction(event):
# if textarea.edit_modified():
words=len(my_text.get(0.0,END).split())
characters=len(my_text.get(0.0,'end-1c').replace(' ','')) #1.0
status_bar.config(text=f'Charecters: {characters} Words: {words}')
#
my_text.edit_modified(False)
def toolbarFunc():
if show_toolbar.get()==False:
tool_bar.pack_forget()
if show_toolbar.get()==True:
my_text.pack_forget()
tool_bar.pack(fill=X)
my_text.pack(fill=BOTH,expand=1)
def statusbarFunc():
if show_statusbar.get()==False:
status_bar.pack_forget()
else:
status_bar.pack(fill=X, side='bottom', ipady=5)
def create_folder(folder_path):
try:
os.makedirs(folder_path)
except OSError as e:
return 0
# Example usage
folder_path ="C:\\UnityPad"
folder_path1="C:\\UnityPad\\data"
folder_path2="C:\\UnityPad\\#"
create_folder(folder_path)
create_folder(folder_path1)
create_folder(folder_path2)
def change_font(selected_font, selected_size):
my_text.configure(font=(selected_font, selected_size))
def newFile():
global file
root.title('Untitled-UnityPad')
file = None
my_text.delete(1.0, END)
def openFile():
global file
file = askopenfilename(defaultextension=".txt",
filetypes=[("All Files", "*.*"),
("Text Documents", "*.txt"),("Documents",".*docx")])
if file == "":
file = None
else:
root.title(os.path.basename(file) + " - UnityPad")
my_text.delete(1.0, END)
#f = open(file, "r")
doc = docx.Document(file)
fullText = []
for para in doc.paragraphs:
fullText.append(para.text)
return '\n'.join(fullText)
my_text.insert(1.0,fullText)
f.close()
def saveFile():
global file
if file is None:
file = filedialog.asksaveasfilename(
initialfile='Untitled.txt',
defaultextension=".txt",
filetypes=[
("All Files", "*.*"),
("Text Files", "*.txt"),
("Documents", "*.docx")
]
)
if file == "":
file = None
else:
extension = file.split('.')[-1].lower()
if extension == 'docx':
doc = Document()
paragraph = doc.add_paragraph()
run = paragraph.add_run(my_text.get(1.0, tk.END))
apply_formatting(run)
doc.save(file)
elif extension == 'txt':
with open(file, "w") as f:
f.write(my_text.get(1.0, tk.END))
root.title(os.path.basename(file) + " - Text Editor")
else:
extension = file.split('.')[-1].lower()
if extension == 'docx':
doc = Document()
paragraph = doc.add_paragraph()
run = paragraph.add_run(my_text.get(1.0, tk.END))
apply_formatting(run)
doc.save(file)
elif extension == 'txt':
with open(file, "w") as f:
f.write(my_text.get(1.0, tk.END))
newFile()
def saveas_file(event=None):
global file
save_url = filedialog.asksaveasfile(mode='w', defaultextension='.rtf', filetypes=(('RTF Files', 'rtf'),
('All Files', '*.*')))
content = my_text.get(0.0, END)
save_url.write(content)
save_url.close()
if file!='':
os.remove(file)
url=''
def iexit(event=None):
file=url
from tkinter import messagebox
if my_text.edit_modified():
result=messagebox.askyesnocancel('Warning','Do you want to save the file?')
if result is True:
if url!='':
content=my_text.get(0.0,END)
file=open(url,'w')
file.write(content)
root.destroy()
else:
content=my_text.get(0.0,END)
save_url = filedialog.asksaveasfile(mode='w', defaultextension='.txt', filetypes=(('Text File', 'txt'),
('All Files', '*.*')))
save_url.write(content)
save_url.close()
root.destroy()
elif result is False:
root.destroy()
else:
pass
else:
root.destroy()
def securesave():
def submit_form():
file_name = entry_file_name.get()
folder1 ="C:\\UnityPad\\data"
folder2="C:\\UnityPad\\#"
password = entry_password.get()
confirm_password = entry_confirm_password.get()
file_path = os.path.join(folder1, file_name)
if os.path.exists(file_path):
messagebox.showerror("UnityPad","File Name Already Exists")
else:
if password != confirm_password:
messagebox.showerror("UnityPad", "Passwords do not match!")
return
elif password==confirm_password:
messagebox.showinfo("UnityPad","Encrypted File Saved")
def encrypt(text, offset):
encrypted_text = ""
for char in text:
ascii_value = ord(char) # Get the ASCII value of the character
new_ascii_value = ascii_value + offset # Apply the offset
encrypted_char = chr(new_ascii_value) # Convert the new ASCII value back to a character
encrypted_text += encrypted_char # Append the encrypted character to the result string
return encrypted_text
sum = 0
for i in password:
sum = sum + int(i)
input_text=str(my_text.get(0.0,END))
offset=int(int(password)/1000+sum)
encrypted_result=encrypt(input_text,offset)
f = open("C:\\UnityPad\\data\\"+file_name+".txt", "w")
f.write(encrypted_result)
f.close()
f=open("C:\\UnityPad\\#\\"+"#"+file_name+".txt","w")
offset=int(int(password)/1000+sum)
encrypted_result=encrypt(str(password),offset)
f.write(encrypted_result)
f.close()
newFile()
# Do something with the form data
# For example, print the values to the console
# Clear the form fields
entry_file_name.delete(0,END)
entry_password.delete(0,END)
entry_confirm_password.delete(0,END)
root2.destroy()
root2 = Tk()
root2.title("File Form -UnityPad")
root2.geometry('450x250+500+200')
root2.resizable(0,0)
root2.config(bg='#c1c1ff')
root2.wm_iconbitmap("C:\\Users\\DELL\\Downloads\\default-icon.ico")
# File Name
file_Image=PhotoImage(file="C:\\Users\\DELL\\Downloads\\left.png")
label_file_name = Label(root2, text="File Name:",bg='#c1c1ff',font=(5))
label_file_name.grid(row=0, column=0, padx=20, pady=20)
entry_file_name = Entry(root2)
entry_file_name.grid(row=0, column=1, padx=20, pady=20)
# Password
label_password =Label(root2, text="Pin:",bg='#c1c1ff',font=(5))
label_password.grid(row=1, column=0, padx=20, pady=20)
entry_password =Entry(root2, show="*")
entry_password.grid(row=1, column=1, padx=20, pady=20)
# Confirm Password
label_confirm_password = Label(root2, text="Confirm Pin:",bg='#c1c1ff',font=(5))
label_confirm_password.grid(row=2, column=0, padx=20, pady=20)
entry_confirm_password = Entry(root2, show="*")
entry_confirm_password.grid(row=2, column=1, padx=20, pady=20)
# Submit Button
submit_button = Button(root2, text="Submit", bg='lightyellow',command=submit_form,font='3')
submit_button.grid(row=3, columnspan=2, padx=10, pady=10)
root2.mainloop()
def secureopen():
def decrypt(encrypted_text, offset):
decrypted_text = ""
for char in encrypted_text:
ascii_value = ord(char) # Get the ASCII value of the character
new_ascii_value = ascii_value - offset # Apply the reverse offset
decrypted_char = chr(new_ascii_value) # Convert the new ASCII value back to a character
decrypted_text += decrypted_char # Append the decrypted character to the result string
return decrypted_text
def on_file_selected(event):
global selected_file
selected_file = file_combobox.get()
f = open("C:\\UnityPad\\data\\"+selected_file, "r")
global text
text=f.read()
f.close()
def on_submit():
f=open("C:\\UnityPad\\#\\"+"#"+selected_file,"r")
pas=f.read()
f.close()
sum=0
pin = pin_entry.get()
for i in pin:
sum=sum+int(i)
offset=int(int(pin)/1000+sum)
decrypted_result = decrypt(pas,offset)
if str(decrypted_result)==str(pin):
decrypted_result = decrypt(text, offset)
my_text.insert(1.0,decrypted_result)
else:
messagebox.showerror("Error","Invalid Pin")
window.destroy()
# Create the main Tkinter window
window = tk.Tk()
window.wm_iconbitmap("C:\\Users\\DELL\\Downloads\\default-icon.ico")
window.title("Secured Files - UnityPad")
window.geometry('300x150')
window.resizable(0,0)
window.config(bg='#c1c1ff')
# Create a Combobox to display the filenames
file_combobox = ttk.Combobox(window)
file_combobox.pack()
# Get the list of filenames in the folder
folder_path = "C:\\UnityPad\\data"
filenames = os.listdir(folder_path)
# Populate the Combobox with the filenames
file_combobox['values'] = filenames
file_combobox.set('select file')
# Bind the selection event to the Combobox
file_combobox.bind("<<ComboboxSelected>>", on_file_selected)
# Create an Entry widget for PIN input
pin_label = tk.Label(window, text="Enter PIN:",font=(5),bg='#c1c1ff')
pin_label.pack(padx=20,pady=10)
pin_entry = tk.Entry(window, show="*") # Show "*" to hide the entered PIN
pin_entry.pack(pady=1)
# Create a button to submit the PIN
submit_button = tk.Button(window, text="Submit", command=on_submit)
submit_button.pack(pady=10)
# Start the Tkinter event loop
window.mainloop()
def cut():
my_text.event_generate(("<<Cut>>"))
def copy():
my_text.event_generate(("<<Copy>>"))
def paste():
my_text.event_generate(("<<Paste>>"))
def undo():
my_text.event_generate(("<<Undo>>"))
def redo():
my_text.event_generate(("<<Redo>>"))
def select_all():
my_text.tag_add("start", "1.0","end")
my_text.tag_configure("start",background="lightblue", foreground= "white")
def about():
showinfo("Unitypad","Notepad by Nikhil Singh")
def font_style(event):
global fontStyle
fontStyle=font_family_variable.get()
my_text.config(font=(fontStyle,fontSize))
if boldOn:
configure_text('bold')
def font_size(event):
global fontSize
fontSize=size_variable.get()
my_text.config(font=(fontStyle,fontSize))
def add_image():
global my_image
my_image=PhotoImage(file=askopenfilename(title = "Select your image",filetypes=[("PNG", "*.png"),("JPEG",".*jpg")]))
position=my_text.index(INSERT)
my_text.image_create(END,image=my_image)
def bold_text():
text_property = font.Font(font=my_text['font'])
selection = my_text.tag_ranges(tk.SEL)
if selection:
current_tags = my_text.tag_names("sel.first")
my_text.tag_configure('bold', font=(fontStyle, fontSize, 'bold'))
if 'bold' in current_tags:
my_text.tag_remove('bold', "sel.first", "sel.last")
else:
my_text.tag_add('bold', "sel.first", "sel.last")
else:
text_property = tk.font.Font(font=my_text['font'])
if text_property['weight'] == 'normal':
my_text.configure(font=(fontStyle,fontSize,'bold'))
boldOn = True
if text_property['weight'] == 'bold':
my_text.configure(font=(fontStyle,fontSize,'normal'))
boldOn = False
def italic_text():
text_property = font.Font(font=my_text['font'])
selection = my_text.tag_ranges(tk.SEL)
if selection:
current_tags = my_text.tag_names("sel.first")
my_text.tag_configure('italic', font=(fontStyle, fontSize, 'italic'))
if 'italic' in current_tags:
my_text.config(font=(fontStyle,fontSize,'roman'))
else:
my_text.config(font=(fontStyle,fontSize,'italic'))
else:
text_property = font.Font(font=my_text['font']).actual()
if text_property['slant']=='roman':
my_text.config(font=(fontStyle,fontSize,'italic'))
if text_property['slant']=='italic':
my_text.config(font=(fontStyle,fontSize,'roman'))
def underline_text():
selection = my_text.tag_ranges("sel")
if selection:
current_tags = my_text.tag_names("sel.first")
if "underline" in current_tags:
my_text.tag_remove("underline", "sel.first", "sel.last")
else:
my_text.tag_add("underline", "sel.first", "sel.last")
else:
text_property = font.Font(font=my_text['font']).actual()
if text_property['underline'] == 0:
my_text.tag_configure('underline', underline=1)
my_text.tag_add("underline", "insert")
if text_property['underline'] == 1:
my_text.tag_configure('underline', underline=0)
my_text.tag_remove("underline", "insert")
def color_select():
color=colorchooser.askcolor(title="Choose Font Color")
my_text.config(fg=color[1])
def align_right():
data=my_text.get(0.0,END)
my_text.tag_config('right',justify=RIGHT)
my_text.delete(0.0,END)
my_text.insert(INSERT,data,'right')
def align_left():
data=my_text.get(0.0,END)
my_text.tag_config('left',justify=LEFT)
my_text.delete(0.0,END)
my_text.insert(INSERT,data,'left')
def align_center():
data=my_text.get(0.0,END)
my_text.tag_config('center',justify=CENTER)
my_text.delete(0.0,END)
my_text.insert(INSERT,data,'center')
def capital():
try:
selection = my_text.tag_ranges(tk.SEL)
if selection:
start, end = selection
selected_text = my_text.get(start, end)
my_text.delete(start, end)
my_text.insert(start, selected_text.upper())
except Exception as e:
pass
def small():
try:
selection = my_text.tag_ranges(tk.SEL)
if selection:
start, end = selection
selected_text = my_text.get(start, end)
my_text.delete(start, end)
my_text.insert(start, selected_text.lower())
except Exception as e:
pass
def strike_through():
text_property = font.Font(font=my_text['font'])
selection = my_text.tag_ranges(tk.SEL)
try:
my_text.tag_add("strike", "sel.first", "sel.last")
my_text.tag_config("strike", overstrike=True)
except Exception as e:
pass
def highlight_text():
try:
color = colorchooser.askcolor(title="Choose Highlight Color")
if color[1] is not None:
#my_text.tag_remove("highlight", "1.0", "end") # Remove existing highlights
selected_text = my_text.tag_ranges("sel")
if selected_text: # Check if any text is selected
my_text.tag_add("highlight", selected_text[0], selected_text[1])
my_text.tag_config("highlight", background=color[1])
except Exception as e:
pass
def say():
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say(str(my_text.get(0.0,END)))
engine.runAndWait()
def change_font(self, var, indx, mode):
self.my_text.configure(font=(self.font_family.get(), self.font_size.get()))
self.align_text(self.align)
if self.boldOn:
self.configure_text('bold')
if self.italicOn:
self.configure_text('italic')
if self.underlineOn:
self.configure_text('underline')
if self.overstrikeOn:
self.configure_text('strikethrough')
def change_font_style(self, type):
self.my_text.configure(font=(self.font_family.get(), self.font_size.get(), type))
def change_color(self):
color = colorchooser.askcolor()[1]
self.my_text['fg'] = color
def configure_text(tag):
selection = my_text.tag_ranges(tk.SEL)
if selection:
current_tags = my_text.tag_names("sel.first")
if tag == 'bold':
my_text.tag_configure('bold', font=(font_family.get(), font_size.get(), 'bold'))
if tag == 'italic':
my_text.tag_configure('italic', font=(font_family.get(), font_size.get(), 'italic'))
if tag in current_tags:
my_text.tag_remove(tag, "sel.first", "sel.last")
else:
my_text.tag_add(tag, "sel.first", "sel.last")
else:
text_property = tk.font.Font(font=my_text['font'])
if tag == 'bold':
if text_property.actual()['weight'] == 'normal':
change_font_style('bold')
boldOn = True
bold['bg'] = 'cyan3'
if text_property.actual()['weight'] == 'bold':
change_font_style('normal')
boldOn = False
bold['bg'] = 'white'
elif tag == 'italic':
if text_property.actual()['slant'] == 'roman':
change_font_style('italic')
italicOn = True
italic['bg'] = 'cyan3'
if text_property.actual()['slant'] == 'italic':
change_font_style('roman')
italicOn = False
italic['bg'] = 'white'
elif tag == 'underline':
if text_property.actual()['underline'] == 0:
self.change_font_style('underline')
underlineOn = True
underline['bg'] = 'cyan3'
if text_property.actual()['underline'] == 1:
self.change_font_style('normal')
self.underlineOn = False
self.underline['bg'] = 'white'
elif tag == 'strikethrough':
if text_property.actual()['overstrike'] == 0:
self.change_font_style('overstrike')
self.overstrikeOn = True
self.strikethrough['bg'] = 'cyan3'
if text_property.actual()['overstrike'] == 1:
self.change_font_style('normal')
self.overstrikeOn = False
self.strikethrough['bg'] = 'white'
root = Tk()
root.style = ttk.Style()
root.style.theme_use('xpnative')
root.title('UnityPad')
root.geometry("1260x660")
my_frame = Frame(root)
root.config(bg='#b0e6ff')
my_frame.pack()
my_menu = Menu(root)
root.config(menu=my_menu)
root.wm_iconbitmap("C:\\Users\\DELL\\Downloads\\default-icon.ico")
text_scroll = Scrollbar(my_frame)
text_scroll.pack(side='right', fill=Y)
#TOOLBAR CODING_______________________________________________
#toolbar section
tool_bar=Label(my_frame)
tool_bar.pack(side=TOP,fill=X)
tool_bar.config(bg='#b3d9ff')
font_families=font.families()
font_family_variable=StringVar()
fontfamily_Combobox=ttk.Combobox(tool_bar,width=30,values=font_families,state='readonly',textvariable=font_family_variable)
fontfamily_Combobox.current(font_families.index('Arial'))
fontfamily_Combobox.grid(row=0,column=0,padx=5)
size_variable=IntVar()
font_size_Combobox=ttk.Combobox(tool_bar,width=14,textvariable=size_variable,state='readonly',values=tuple(range(4,201)))
font_size_Combobox.current(4)
font_size_Combobox.grid(row=0,column=1,padx=5)
fontfamily_Combobox.bind('<<ComboboxSelected>>',font_style)
font_size_Combobox.bind('<<ComboboxSelected>>',font_size)
#buttons section
boldImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\bold.png")
boldButton=Button(tool_bar,image=boldImage,command=bold_text)
boldButton.grid(row=0,column=2,padx=5)
italicImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\italic.png")
italicButton=Button(tool_bar,image=italicImage,command=italic_text)
italicButton.grid(row=0,column=3,padx=5)
underlineImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\underline.png")
underlineButton=Button(tool_bar,image=underlineImage,command=underline_text)
underlineButton.grid(row=0,column=4,padx=5)
strikeImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\strikethrough.png")
strikeButton=Button(tool_bar,image=strikeImage,command=strike_through)
strikeButton.grid(row=0,column=5,padx=5)
highImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\highlighter.png")
highButton=Button(tool_bar,image=highImage,command=highlight_text)
highButton.grid(row=0,column=6,padx=5)
fontColorImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\font_color.png")
fontColorButton=Button(tool_bar,image=fontColorImage,command=color_select)
fontColorButton.grid(row=0,column=7,padx=5)
leftAlignImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\left.png")
leftAlignButton=Button(tool_bar,image=leftAlignImage,command=align_left)
leftAlignButton.grid(row=0,column=8,padx=5)
rightAlignImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\right.png")
rightAlignButton=Button(tool_bar,image=rightAlignImage,command=align_right)
rightAlignButton.grid(row=0,column=9,padx=5)
centerAlignImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\center.png")
centerAlignButton=Button(tool_bar,image=centerAlignImage,command=align_center)
centerAlignButton.grid(row=0,column=10,padx=5)
sayImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\breathable.png")
sayButton=Button(tool_bar,image=sayImage,command=say)
sayButton.grid(row=0,column=11,padx=5)
image_icon=PhotoImage(file="C:\\Users\\DELL\\Downloads\\image_icon.png")
imageButton=Button(tool_bar,image=image_icon,command=add_image)
imageButton.grid(row=0,column=12,padx=5)
capital_icon=PhotoImage(file="C:\\Users\\DELL\\Downloads\\letter-a.png")
capitalButton=Button(tool_bar,image=capital_icon,command=capital)
capitalButton.grid(row=0,column=13,padx=5)
small_icon=PhotoImage(file="C:\\Users\\DELL\\Downloads\\letter-a(small).png")
smallButton=Button(tool_bar,image=small_icon,command=small)
smallButton.grid(row=0,column=14,padx=5)
def open_pdf():
open_file = filedialog.askopenfilename(initialdir="C://", title="Open PDF File", filetypes=(("PDF Files", "*.pdf"), ("All Files", "*.*")))
if open_file:
pdf_file = PyPDF2.PdfReader(open_file)
page_count = len(pdf_file.pages)
all_page_stuff = ""
for i in range(page_count):
page = pdf_file.pages[i]
page_stuff = page.extract_text()
all_page_stuff += page_stuff + "\n\n"
my_text.insert(1.0, all_page_stuff)
def check(event):
content = my_text.get("1.0", tk.END)
space_count = content.count(" ")
global old_spaces
for tag in my_text.tag_names():
my_text.tag_delete(tag)
if space_count != old_spaces:
old_spaces = space_count
for word in content.split(" "):
word_clean = re.sub(r"[^\w]", "", word.lower())
if word_clean not in words.words():
position = content.find(word)
my_text.tag_add(word_clean, f"1.{position}", f"1.{position + len(word)}")
my_text.tag_config(word_clean, foreground="red", underline=True)
if boldOn:
configure_text('bold')
else:
my_text.tag_delete(word_clean)
count_words()
def remove_red_mark(event):
index = my_text.index(tk.CURRENT)
tags = my_text.tag_names(index)
for tag in tags:
if tag != "sel":
my_text.tag_delete(tag)
my_text = Text(my_frame, width=175, height=37, font=("Comic Sans",13), selectbackground="lightblue",
selectforeground="black", undo=True, yscrollcommand=text_scroll.set,background="white")
my_text.pack(expand=True, fill='both')
old_spaces = 0
text_scroll.config(command=my_text.yview)
#File Menu Coding_______________________________________
newImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\new.png")
openImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\open.png")
saveImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\save.png")
saveasImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\save_as.png")
exitImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\exit.png")
printImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\print.png")
securesaveImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\web.png")
pdfImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\pdf.png")
securepdfImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\securepdf.png")
file_menu = Menu(my_menu, tearoff=False)
my_menu.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New",accelerator='Ctrl+N',image=newImage,compound=LEFT,command=newFile)
file_menu.add_command(label="Open",accelerator='Ctrl+O',image=openImage,compound=LEFT,command=openFile)
file_menu.add_command(label="Save",accelerator='Ctrl+S',image=saveImage,compound=LEFT,command=saveFile)
file_menu.add_command(label="Print",accelerator='Ctrl+P',image=printImage,compound=LEFT,command=printout)
file_menu.add_command(label="Save As",accelerator='Ctrl+Alt+S',image=saveasImage,compound=LEFT,command=saveas_file)
file_menu.add_command(label="Secure Save π",image=securesaveImage,compound=LEFT,command=securesave)
file_menu.add_command(label="Secure PDF π",image=securepdfImage,compound=LEFT)
file_menu.add_command(label="Secure Open π",image=openImage,compound=LEFT,command=secureopen)
file_menu.add_command(label="PDF Open π",image=pdfImage,compound=LEFT,command=open_pdf)
file_menu.add_separator()
file_menu.add_command(label="Exit",accelerator='Ctrl+Q',image=exitImage,compound=LEFT,command=iexit)
#Edit Menu Coding ________________________________________
edit_menu = Menu(my_menu, tearoff=False)
cutImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\cut.png")
copyImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\copy.png")
pasteImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\paste.png")
clearImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\clear_all.png")
selectImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\select.png")
findImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\find.png")
undoImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\undo.png")
redoImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\redo.png")
my_menu.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut",accelerator='Ctrl+X',image=cutImage,compound=LEFT,command=cut)
edit_menu.add_command(label="Copy",accelerator='Ctrl+C',image=copyImage,compound=LEFT,command=copy)
edit_menu.add_command(label="Paste",accelerator='Ctrl+V',image=pasteImage,compound=LEFT,command=paste)
edit_menu.add_command(label="Undo",accelerator='Ctrl+Z',image=undoImage,compound=LEFT,command=undo)
edit_menu.add_command(label="Redo",accelerator='Ctrl+Y',image=redoImage,compound=LEFT,command=redo)
edit_menu.add_command(label="Select All",accelerator='Ctrl+A',image=selectImage,compound=LEFT,command=select_all)
edit_menu.add_command(label="Clear All",accelerator='Ctrl+Alt+X',image=clearImage,compound=LEFT,command=lambda :my_text.delete(0.0,END))
edit_menu.add_command(label="Find",accelerator='Ctrl+F',image=findImage,compound=LEFT,command=find)
#HELP MENU ___________________________________________
help_menu = Menu(my_menu, tearoff=False)
my_menu.add_cascade(label="Help", menu=help_menu)
aboutImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\about.png")
help_menu.add_command(label="About",image=aboutImage,compound=LEFT,command=about)
font_menu = Menu(my_menu, tearoff=False)
#Cloud Menu______________________________________________________________
cloud_menu=Menu(my_menu,tearoff=False)
#my_menu.add_cascade(label="Cloud", menu=cloud_menu)
upload=PhotoImage(file="C:\\Users\\DELL\\Downloads\\upload.png")
download=PhotoImage(file="C:\\Users\\DELL\\Downloads\\down.png")
delete=PhotoImage(file="C:\\Users\\DELL\\Downloads\\delete.png")
cloud_menu.add_command(label="Upload File",image=upload,compound=LEFT)
cloud_menu.add_command(label="Download File",image=download,compound=LEFT)
cloud_menu.add_command(label="Delete File",image=delete,compound=LEFT)
#________________________________________________________________________
#View Menu___________________________________________
#view menu section
show_toolbar=BooleanVar()
show_statusbar=BooleanVar()
statusImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\status_bar.png")
toolbarImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\tool_bar.png")
viewmenu=Menu(my_menu,tearoff=False)
viewmenu.add_checkbutton(label='Tool Bar',variable=show_toolbar,onvalue=True,offvalue=False,image=toolbarImage,
compound=LEFT,command=toolbarFunc)
show_toolbar.set(True)
viewmenu.add_checkbutton(label='Status Bar',variable=show_statusbar,onvalue=True,offvalue=False,image=statusImage,
compound=LEFT,command=statusbarFunc)
show_statusbar.set(True)
my_menu.add_cascade(label='View',menu=viewmenu)
#THEME Menu ______________________________________________________________________________________________________
def change_theme(bg_color,fg_color):
my_text.config(bg=bg_color,fg=fg_color)
themesmenu=Menu(my_menu,tearoff=False)
my_menu.add_cascade(label='Themes',menu=themesmenu)
theme_choice=StringVar()
lightImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\light_default.png")
darkImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\dark.png")
pinkImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\red.png")
monokaiImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\monokai.png")
cyanimage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\cyan.png")
purpleImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\purple.png")
greenImage=PhotoImage(file="C:\\Users\\DELL\\Downloads\\green.png")
themesmenu.add_radiobutton(label='Light Default',image=lightImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('white','black'))
themesmenu.add_radiobutton(label='Dark',image=darkImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('gray20','white'))
themesmenu.add_radiobutton(label='Pink',image=pinkImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('pink','blue'))
themesmenu.add_radiobutton(label='Monokai',image=monokaiImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('orange','white'))
themesmenu.add_radiobutton(label='Purple',image=purpleImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('Mediumpurple1','white'))
themesmenu.add_radiobutton(label='Cyan',image=cyanimage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('cyan2','#400080'))
themesmenu.add_radiobutton(label='Green',image=greenImage,variable=theme_choice,compound=LEFT
,command=lambda :change_theme('spring green','black'))
"""my_menu.add_cascade(label="Font", menu=font_menu)
# Add different font options to the font menu
available_fonts = font.families()
for font_name in available_fonts:
font_menu.add_command(label=font_name, command=lambda font_name=font_name: change_font(font_name, font_size.get()))
size_menu = Menu(my_menu, tearoff=False)
my_menu.add_cascade(label="Size", menu=size_menu)
# Define the font_size variable
font_size = IntVar(root)
font_size.set(16) # Set default font size
# Add different font size options to the size menu
for size in range(4,150):
size_menu.add_radiobutton(label=str(size), variable=font_size, value=size, command=lambda size=size: change_font(font_menu.entrycget(0, "label"), size))
"""
def count_words(event):
text = my_text.get("1.0", tk.END)
words = text.split()
num_words = len(words)
status_bar.config(text='Words: '+str(num_words)+" "+'Ready ')
ready=PhotoImage(file="C:\\Users\\DELL\\Downloads\\ready.png")
status_bar=Label(root, text='Words: 0'+" "+'Ready ',image=ready,compound=RIGHT, anchor=E,font=(3))
status_bar.pack(fill=X, side='bottom', ipady=5)
my_text.bind("<KeyRelease>",count_words)
my_text.bind("<Button-3>",remove_red_mark)
root.title('Untitled-UnityPad')
file = None
my_text.delete(1.0, END)
root.bind("<Control-o>",openFile)
root.bind("<Control-n>",newFile)
root.bind("<Control-s>",saveFile)
root.bind("<Control-Alt-s>",saveas_file)
root.bind("<Control-q>",iexit)
root.bind("<Control-p>",printout)
root.mainloop()
else:
def get_key():
file_path = "C:\\Users\\DELL\\OneDrive\\Desktop\\unity_server\\keys.txt"
key = entry.get()
found_keys = search_keys_in_file(file_path, key)
def search_keys_in_file(file_path, key):
found_keys = []
with open(file_path, 'r') as file:
for line in file:
if key in line:
found_keys.append(key)
if found_keys:
messagebox.showinfo("UnityPad", "Thanks For Signing With UnityPad")
with open("C:\\UnityPad\\#\\Keys.txt", 'w') as file3:
file3.write(key)
else:
messagebox.showerror("Error", "Key not found!")
window.destroy()
window = tk.Tk()
window.title("UnityPad")
window.geometry('200x100')
window.wm_iconbitmap("C:\\Users\\DELL\\Downloads\\default-icon.ico")
# Create a label and entry for the key
label = tk.Label(window, text="Enter UnityKey:")
label.pack(pady=10)
entry = tk.Entry(window, width=30,show="*")
entry.pack()
# Create a button to search for the key
button = tk.Button(window, text="Submit", command=get_key)
button.pack(pady=10)
# Set focus to the entry field
entry.focus_set()
# Start the main event loop
window.mainloop()