-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblack
More file actions
770 lines (732 loc) · 30.4 KB
/
black
File metadata and controls
770 lines (732 loc) · 30.4 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
#!/usr/bin/python3
# Black-Notepad v1.0
#
from tkinter import *
from tkinter.ttk import *
from tkinter.messagebox import *
import os,sys
from webbrowser import open_new_tab
from subprocess import getoutput
import tkinter.filedialog
import tkinter.messagebox
from tkhtmlview import HTMLLabel
from ttkbootstrap import Style
root = Tk()
st = Style("darkly")
title_ = "Black Notepad"
root.title(title_)
file_name = None
root.geometry('800x700+300+50')
root.iconphoto(False,PhotoImage(file='./Scr/blacknotepad-logo.png'))
def new_file(event=None):
root.title("Black-Notepad Untitled")
global file_name
file_name = None
content_text.delete(1.0, END)
on_content_changed()
def open_file(event=None):
try:
input_file_name = tkinter.filedialog.askopenfilename(title="Open File",defaultextension=".txt",filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt"),("HTML", "*.html"),("CSS", "*.css"),("JavaScript", "*.js")])
if input_file_name:
global file_name
file_name = input_file_name
root.title('{} - {}'.format(os.path.basename(file_name), title_))
content_text.delete(1.0, END)
with open(file_name) as _file:
content_text.insert(1.0, _file.read())
on_content_changed()
notebook.add(tab1,text=os.path.basename(file_name))
except (Exception,TypeError,):
pass
def write_to_file(file_name):
try:
content = content_text.get(1.0, 'end')
with open(file_name, 'w') as the_file:
the_file.write(content)
the_file.close()
except IOError:
pass
def save_as(event=None):
try:
input_file_name = tkinter.filedialog.asksaveasfilename(title="Save As",defaultextension=".txt",filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt"),("HTML", "*.html"),("CSS", "*.css"),("JavaScript", "*.js")])
if input_file_name:
global file_name
file_name = input_file_name
write_to_file(file_name)
root.title('{} - {}'.format(os.path.basename(file_name), title_))
notebook.add(tab1,os.path.basename(file_name))
return "break"
except (Exception,TypeError,):
pass
def save(event=None):
global file_name
if not file_name:
try:
input_file_name = tkinter.filedialog.asksaveasfilename(title="Save",defaultextension=".txt",filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt"),("HTML", "*.html"),("CSS", "*.css"),("JavaScript", "*.js")])
if input_file_name:
file_name = input_file_name
write_to_file(file_name)
root.title('{} - {}'.format(os.path.basename(file_name), title_))
notebook.add(tab1,os.path.basename(file_name))
return "break"
except (Exception,TypeError,):
pass
else:
write_to_file(file_name)
return "break"
def cut():
content_text.event_generate("<<Cut>>")
on_content_changed()
return "break"
def copy():
content_text.event_generate("<<Copy>>")
on_content_changed()
return "break"
def paste():
content_text.event_generate("<<Paste>>")
on_content_changed()
return "break"
def undo():
content_text.event_generate("<<Undo>>")
on_content_changed()
return "break"
def redo(event=None):
content_text.event_generate("<<Redo>>")
on_content_changed()
return "break"
def selectall(event=None):
content_text.tag_add('sel','1.0','end')
return "break"
def find_text(event=None):
search_toplevel = Toplevel(root)
search_toplevel.title('Find Text')
search_toplevel.transient(root)
search_toplevel.resizable(False, False)
Label(search_toplevel, text="Find All:").grid(row=0, column=0, sticky='e')
search_entry_widget = Entry(search_toplevel, width=25)
search_entry_widget.grid(row=0, column=1, padx=2, pady=2, sticky='we')
search_entry_widget.focus_set()
ignore_case_value = IntVar()
Checkbutton(search_toplevel, text='Ignore Case', variable=ignore_case_value).grid(row=1, column=1, sticky='e', padx=2, pady=2)
Button(search_toplevel, text="Find All", underline=0,
command=lambda: search_output(
search_entry_widget.get(), ignore_case_value.get(),
content_text, search_toplevel, search_entry_widget)
).grid(row=0, column=2, sticky='e' + 'w', padx=2, pady=2)
def close_search_window():
content_text.tag_remove('match', '1.0', END)
search_toplevel.destroy()
search_toplevel.protocol('WM_DELETE_WINDOW', close_search_window)
return "break"
def get_line_numbers():
output = ''
if show_line_number.get():
row, col = content_text.index("end").split('.')
for i in range(1, int(row)):
output += str(i) + '\n'
return output
def on_content_changed(event=None):
update_line_numbers()
update_cursor()
def update_line_numbers(event=None):
line_numbers = get_line_numbers()
line_number_bar.config(state='normal')
line_number_bar.delete('1.0', 'end')
line_number_bar.insert('1.0', line_numbers)
line_number_bar.config(state='disabled')
def show_cursor():
show_cursor_info_checked = show_cursor_info.get()
if show_cursor_info_checked:
cursor_info_bar.pack(expand='no', fill=None, side='right', anchor='se')
else:
cursor_info_bar.pack_forget()
def update_cursor(event=None):
row, col = content_text.index(INSERT).split('.')
line_num, col_num = str(int(row)), str(int(col) + 1)
infotext = "Line: {0} | Column: {1}".format(line_num, col_num)
cursor_info_bar.config(text=infotext)
def highlight_line(interval=100):
content_text.tag_remove("active_line", 1.0, "end")
content_text.tag_add(
"active_line", "insert linestart", "insert lineend+1c")
content_text.after(interval, toggle_highlight)
def get_line_numbers():
output = ''
if show_line_number.get():
row, col = content_text.index("end").split('.')
for i in range(1, int(row)):
output += str(i) + '\n'
return output
def on_content_changed(event=None):
update_line_numbers()
update_cursor()
def update_line_numbers(event=None):
line_numbers = get_line_numbers()
line_number_bar.config(state='normal')
line_number_bar.delete('1.0', 'end')
line_number_bar.insert('1.0', line_numbers)
line_number_bar.config(state='disabled')
def show_cursor():
show_cursor_info_checked = show_cursor_info.get()
if show_cursor_info_checked:
cursor_info_bar.pack(expand='no', fill=None, side='right', anchor='se')
else:
cursor_info_bar.pack_forget()
def update_cursor(event=None):
row, col = content_text.index(INSERT).split('.')
line_num, col_num = str(int(row)), str(int(col) + 1)
infotext = "Line: {0} | Column: {1}".format(line_num, col_num)
cursor_info_bar.config(text=infotext)
def highlight_line(interval=100):
content_text.tag_remove("active_line", 1.0, "end")
content_text.tag_add(
"active_line", "insert linestart", "insert lineend+1c")
content_text.after(interval, toggle_highlight)
def undo_highlight():
content_text.tag_remove("active_line", 1.0, "end")
def toggle_highlight(event=None):
if to_highlight_line.get():
highlight_line()
else:
undo_highlight()
def search_output(needle,if_ignore_case, content_text, search_toplevel, search_box):
content_text.tag_remove('match','1.0', END)
matches_found=0
if needle:
start_pos = '1.0'
while True:
start_pos = content_text.search(needle,start_pos, nocase=if_ignore_case, stopindex=END)
if not start_pos:
break
end_pos = '{} + {}c'. format(start_pos, len(needle))
content_text.tag_add('match', start_pos, end_pos)
matches_found +=1
start_pos = end_pos
content_text.tag_config('match', background='yellow', foreground='blue')
search_box.focus_set()
search_toplevel.title('{} matches found'.format(matches_found))
def exit_editor(event=None):
if content_text.get(1.0,'end-1c') != '':
try:
if not file_name:
q = tkinter.messagebox.askyesnocancel(title="Black-Notepad",message="Do you want to Save File And Exit Program? ")
if q:
file = tkinter.filedialog.asksaveasfile(title="Save File",mode="w")
file.write(content_text.get(1.0,'end-1c'))
file.close()
root.destroy()
elif q == None:
pass
else:
root.destroy()
else:
q = tkinter.messagebox.askyesnocancel(title="Black-Notepad",message="Do you want to Save File And Exit Program? ")
if q:
file_s = open(file_name,"w")
file_s.write(content_text.get(1.0,'end-1c'))
file_s.close()
root.destroy()
elif q == None:
pass
else:
root.destroy()
except (Exception,):
pass
else:
q = tkinter.messagebox.askyesno(title="Black-Notepad",message="Do you want to exit the program?")
if q:
root.destroy()
else:
pass
def on_content_changed(event=None):
update_line_numbers()
update_cursor()
def update_line_numbers(event=None):
line_numbers = get_line_numbers()
line_number_bar.config(state='normal')
line_number_bar.delete('1.0', 'end')
line_number_bar.insert('1.0', line_numbers)
line_number_bar.config(state='disabled')
def show_cursor():
show_cursor_info_checked = show_cursor_info.get()
if show_cursor_info_checked:
cursor_info_bar.pack(expand='no', fill=None, side='right', anchor='se')
else:
cursor_info_bar.pack_forget()
def update_cursor(event=None):
row, col = content_text.index(INSERT).split('.')
line_num, col_num = str(int(row)), str(int(col) + 1)
infotext = "Line: {0} | Column: {1}".format(line_num, col_num)
cursor_info_bar.config(text=infotext)
def highlight_line(interval=100):
content_text.tag_remove("active_line", 1.0, "end")
content_text.tag_add(
"active_line", "insert linestart", "insert lineend+1c")
content_text.after(interval, toggle_highlight)
def undo_highlight():
content_text.tag_remove("active_line", 1.0, "end")
def toggle_highlight(event=None):
if to_highlight_line.get():
highlight_line()
else:
undo_highlight()
def change_theme(event=None):
selected_theme = theme_choice.get()
fg_bg_colors = color_schemes.get(selected_theme)
foreground_color, background_color = fg_bg_colors.split('.')
content_text.config(
background=background_color, fg=foreground_color)
def show_popup_menu(event):
popup_menu.tk_popup(event.x_root, event.y_root)
def new_window(event=None):
getoutput("python black.py")
def print_paper(event=None):
try:
getoutput(f"print {file_name} /c /d:lpt1")
except (Exception,):
print(False)
def delete(event=None):
content_text.delete('1.0',END)
def reload(event=None):
content_text.event_generate("<<Reload>>")
menu_bar = Menu(root)
file_menu = Menu(menu_bar, tearoff=0)
file_menu.add_command(label='New', accelerator='Ctrl+N', compound='left', command=new_file)
file_menu.add_command(label="New Window",accelerator='Ctrl+Shift+N',compound='left',command=new_window)
file_menu.add_command(label='Open', accelerator='Ctrl+O', compound='left', command=open_file)
file_menu.add_command(label="Save", accelerator='Ctrl+S', compound='left', command=save)
file_menu.add_command(label="Save As", accelerator='Ctrl+Shift+S', compound='left', underline=0, command=save_as)
file_menu.add_separator()
file_menu.add_command(label="Print",command=print_paper)
file_menu.add_separator()
file_menu.add_command(label="Exit", accelerator='Alt+F4', compound='left', underline=0, command=exit_editor)
menu_bar.add_cascade(label='File', menu=file_menu)
edit_menu = Menu(menu_bar, tearoff=0)
edit_menu.add_command(label='Undo', accelerator='Ctrl+Z', compound='left', command=undo)
edit_menu.add_command(label='Redo', accelerator='Ctrl+Y', compound='left',command=redo)
edit_menu.add_separator()
edit_menu.add_command(label='Cut', accelerator='Ctrl+X', compound='left', command=cut)
edit_menu.add_command(label='Copy', accelerator='Ctrl+C', compound='left', command=copy)
edit_menu.add_command(label='Paste', accelerator='Ctrl+V', compound='left', command=paste)
edit_menu.add_separator()
edit_menu.add_command(label='Find', accelerator='Ctrl+F', compound='left', command=find_text)
edit_menu.add_separator()
edit_menu.add_command(label="Reload",accelerator='Ctrl+R',command=reload)
edit_menu.add_command(label="Delete",accelerator='Delete',command=delete)
edit_menu.add_separator()
edit_menu.add_command(label='Select All', accelerator='Ctrl+A', compound='left', command=selectall)
menu_bar.add_cascade(label='Edit', menu=edit_menu)
view_menu = Menu(menu_bar, tearoff=0)
show_line_number=IntVar()
show_line_number.set(1)
view_menu.add_checkbutton(label="Show Line Number", variable=show_line_number)
show_cursor_info=IntVar()
show_cursor_info.set(1)
view_menu.add_checkbutton(label='Show Cursor Location at Bottom', variable=show_cursor_info, command=show_cursor)
to_highlight_line=IntVar()
view_menu.add_checkbutton(label='Highlight Current Line', variable=to_highlight_line, onvalue=1, offvalue=0,command=toggle_highlight)
themes_menu=Menu(menu_bar, tearoff=0)
view_menu.add_cascade(label='Themes', menu=themes_menu, command=change_theme)
''' THEMES OPTIONS'''
color_schemes = {
'Hacker':'lightgreen.#111111',
'Default': '#000000.#FFFFFF',
'Greygarious': '#83406A.#D1D4D1',
'Aquamarine': '#5B8340.#D1E7E0',
'Bold Beige': '#4B4620.#FFF0E1',
'Cobalt Blue': '#ffffBB.#3333aa',
'Olive Green': '#D1E7E0.#5B8340',
'Night Mode': '#FFFFFF.#000000',
}
theme_choice=StringVar()
theme_choice.set('Default')
for k in sorted(color_schemes):
themes_menu.add_radiobutton(label=k, variable=theme_choice, command=change_theme)
fstyle = "None"
fsize = 15
def _10():
global fsize
fsize = 10
content_text.configure(font=(fstyle,fsize))
def _20():
global fsize
fsize = 20
content_text.configure(font=(fstyle,fsize))
def _30():
global fsize
fsize = 30
content_text.configure(font=(fstyle,fsize))
def _40():
global fsize
fsize = 40
content_text.configure(font=(fstyle,fsize))
def _50():
global fsize
fsize = 50
content_text.configure(font=(fstyle,fsize))
def _60():
global fsize
fsize = 60
content_text.configure(font=(fstyle,fsize))
def _70():
global fsize
fsize = 70
content_text.configure(font=(fstyle,fsize))
def _80():
global fsize
fsize = 80
content_text.configure(font=(fstyle,fsize))
def _90():
global fsize
fsize = 90
content_text.configure(font=(fstyle,fsize))
def _100():
global fsize
fsize = 100
content_text.configure(font=(fstyle,fsize))
def none_style():
global fstyle
fstyle = "None"
content_text.configure(font=(fstyle,fsize))
def cooper_style():
global fstyle
fstyle = "Cooper"
content_text.configure(font=(fstyle,fsize))
def Corbel_style():
global fstyle
fstyle = "Corbel"
content_text.configure(font=(fstyle,fsize))
def Courier_style():
global fstyle
fstyle = "Courier"
content_text.configure(font=(fstyle,fsize))
def Dubai_style():
global fstyle
fstyle = "Dubai"
content_text.configure(font=(fstyle,fsize))
def Elephant_style():
global fstyle
fstyle = "Elephant"
content_text.configure(font=(fstyle,fsize))
def E_style():
global fstyle
fstyle = "Edwardian Script ITC"
content_text.configure(font=(fstyle,fsize))
def Footlight_style():
global fstyle
fstyle = "Footlight MT"
content_text.configure(font=(fstyle,fsize))
def Gigi_style():
global fstyle
fstyle = "Gigi"
content_text.configure(font=(fstyle,fsize))
def set_si(event=None):
global fsize
fsize = s_i.get()
content_text.configure(font=(fstyle,fsize))
def set_st(event=None):
global fstyle
fstyle = ss_i.get()
content_text.configure(font=(fstyle,fsize))
def set_size():
global s_i
root = Tk()
root.title("Black-Notepad/Set-Size")
root.geometry("300x200+500+100")
s_i = Spinbox(root,from_=1,to=500)
s_i.place(bordermode=INSIDE,x=80,y=15)
set_b = Button(root,text="Set",width=5,height=2,command=set_si)
set_b.place(bordermode=OUTSIDE,x=125,y=42)
exit_b = Button(root,text="Exit",width=5,height=2,command=root.destroy)
exit_b.place(bordermode=OUTSIDE,x=125,y=86)
root.bind("<Return>",set_si)
root.attributes('-toolwindow',True)
root.mainloop()
def set_style():
global ss_i
root = Tk()
root.title("Black-Notepad/Set-Style")
root.geometry("300x200+500+100")
ss_i = Entry(root,border=3)
ss_i.place(bordermode=INSIDE,x=80,y=15)
set_b = Button(root,text="Set",width=5,height=2,command=set_st)
set_b.place(bordermode=OUTSIDE,x=125,y=42)
exit_b = Button(root,text="Exit",width=5,height=2,command=root.destroy)
exit_b.place(bordermode=OUTSIDE,x=125,y=86)
root.bind("<Return>",set_st)
root.attributes('-toolwindow',True)
root.mainloop()
font_style = Menu(view_menu,tearoff=0)
font_size = Menu(view_menu,tearoff=0)
font_style.add_command(label="None",command=none_style)
font_style.add_command(label="Cooper",command=cooper_style)
font_style.add_command(label="Corbel",command=Corbel_style)
font_style.add_command(label="Courier",command=Courier_style)
font_style.add_command(label="Dubai",command=Dubai_style)
font_style.add_command(label="Edwardian Script ITC",command=E_style)
font_style.add_command(label="Elephant",command=Elephant_style)
font_style.add_command(label="Footlight MT",command=Footlight_style)
font_style.add_command(label="Gigi",command=Gigi_style)
font_style.add_separator()
font_style.add_command(label="Set Style",command=set_style)
font_size.add_command(label=10,command=_10)
font_size.add_command(label=20,command=_20)
font_size.add_command(label=30,command=_30)
font_size.add_command(label=40,command=_40)
font_size.add_command(label=50,command=_50)
font_size.add_command(label=60,command=_60)
font_size.add_command(label=70,command=_70)
font_size.add_command(label=80,command=_80)
font_size.add_command(label=90,command=_90)
font_size.add_command(label=100,command=_100)
font_size.add_separator()
font_size.add_command(label="Set Size",command=set_size)
view_menu.add_cascade(label="Font Style",menu=font_style)
view_menu.add_cascade(label="Font Size",menu=font_size)
menu_bar.add_cascade(label='View', menu=view_menu)
def help(event=None):
open_new_tab('https://black-software-com.github.io/Black-Help/')
def feedback(event=None):
open_new_tab('https://github.com/black-software-Com/Black-Notepad/issues')
def instagram():
open_new_tab('https://instagram.com/black_software_company')
def license(event=None):
open_new_tab('https://github.com/black-software-Com/Black-Help/blob/master/LICENSE')
def about():
global amenu,ammenu
win = Tk()
win.title('Black-Notepad/About')
win.geometry("700x600+550+130")
win.resizable(0,0)
txt_a = '''
Black Notepad
(Gui)
'''
photo = PhotoImage(file='./Scr/black-notepad-logo.png')
win.iconphoto(False,photo)
amenu = Menu(win,tearoff=0)
filemenu = Menu(amenu,tearoff=0)
filemenu.add_command(label='Help',accelerator='Ctrl+H',command=help)
filemenu.add_separator()
filemenu.add_command(label='Exit',accelerator='Alt+F4',command=win.destroy)
amenu.add_cascade(label='Options',menu=filemenu)
ammenu = Menu(win,tearoff=0)
ammenu.add_cascade(label='Help',command=help)
ammenu.add_separator()
ammenu.add_cascade(label='Exit',command=win.destroy)
win.config(menu=amenu)
label_i = Label(win,text='Black Notepad',foreground='black',font=("None",28))
label_i.place(bordermode=INSIDE,x=130,y=15)
label_t = Label(win,text=txt_a,foreground='black',font=("None",10))
label_t.place(bordermode=INSIDE,x=175,y=65)
b = HTMLLabel(win,html='<a title="Black Software" href="https://black-software-com.github.io/Black-Software/" taregt="_blank"> Black </a>')
b.place(bordermode=INSIDE,x=20,y=200)
g = HTMLLabel(win,html='<a href="https://github.com/black-software-com" target="_blank"> Github </a>')
g.place(bordermode=INSIDE,x=20,y=230)
f = HTMLLabel(win,html='<a href="https://www.facebook.com/profile.php?id=100071465381949" target="_blank"> Facebook </a>')
f.place(bordermode=INSIDE,x=20,y=260)
i = HTMLLabel(win,html='<a href="https://instagram.com/black_software_company" target="_blank"> Instagram</a>')
i.place(bordermode=INSIDE,x=20,y=290)
t = HTMLLabel(win,html='<a href="https://twitter.com/blacksoftware3" target="_blank"> Twitter </a>')
t.place(bordermode=INSIDE,x=20,y=320)
tl = HTMLLabel(win,html='<a href="https://t.me/blacksoftware3" target="_blank"> Telegram </a>')
tl.place(bordermode=INSIDE,x=20,y=350)
z = HTMLLabel(win,html='<a href="https://zil.ink/blacksoftware" target="_blank"> ZLink </a>')
z.place(bordermode=INSIDE,x=20,y=380)
fl = Label(win,text='© Black Software')
fl.place(bordermode=INSIDE,x=280,y=530)
root.bind("<Control-h>",help)
root.bind("<Button-3>",do_popupa)
root.mainloop()
def do_popupa(self,event):
try:
ammenu.tk_popup(event.x_root,event.y_root)
finally:
ammenu.grab_release()
about_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label='About', menu=about_menu)
about_menu.add_command(label='Help', accelerator='Ctrl+H',underline=0, command=help)
about_menu.add_command(label="Join On Instagram",command=instagram)
about_menu.add_separator()
about_menu.add_command(label="View License",accelerator='Ctrl+L',command=license)
about_menu.add_command(label="Send Feedback",accelerator='Ctrl+F',command=feedback)
about_menu.add_separator()
about_menu.add_command(label="About",command=about)
root.config(menu=menu_bar)
global file_cha_
file_cha = open("./Core/ch_about","r").read()
file_cha_ = int(file_cha)
if file_cha_ == 0 or file_cha_ == 1 or file_cha_ == 2 or file_cha_ == 3:
global tab1
notebook = Notebook(width=200, height=200)
notebook.pack(side="top", fill="both", expand=True)
tab1 = Frame(notebook)
tab2 = Frame(notebook)
notebook.add(tab1,text='UnTitled')
notebook.add(tab2,text="Read.txt")
l = Label(tab2,text="Black-Notepad (Beta)",font=("None",25))
l.place(bordermode=INSIDE,x=240,y=15)
l_txt = Label(tab2,text="Black-Notepad v2.0 Coming Soon...",font=("None",15))
l_txt.place(x=235,y=130)
g = HTMLLabel(tab2,html='<a href="https://github.com/black-software-com" target="_blank"> Github </a>')
g.place(bordermode=INSIDE,x=20,y=230)
f = HTMLLabel(tab2,html='<a href="https://www.facebook.com/profile.php?id=100071465381949" target="_blank"> Facebook </a>')
f.place(bordermode=INSIDE,x=20,y=260)
i = HTMLLabel(tab2,html='<a href="https://instagram.com/black_software_company" target="_blank"> Instagram</a>')
i.place(bordermode=INSIDE,x=20,y=290)
t = HTMLLabel(tab2,html='<a href="https://twitter.com/blacksoftware3" target="_blank"> Twitter </a>')
t.place(bordermode=INSIDE,x=20,y=320)
tl = HTMLLabel(tab2,html='<a href="https://t.me/blacksoftware3" target="_blank"> Telegram </a>')
tl.place(bordermode=INSIDE,x=20,y=350)
z = HTMLLabel(tab2,html='<a href="https://zil.ink/blacksoftware" target="_blank"> ZLink </a>')
z.place(bordermode=INSIDE,x=20,y=380)
fl = Label(tab2,text='© Black Software')
fl.place(bordermode=INSIDE,x=360,y=530)
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
file_cha_ += 1
file_cha = open("./Core/ch_About","w")
file_cha.write(str(file_cha_))
file_cha.close()
else:
notebook = Notebook(width=200, height=200)
notebook.pack(side="top", fill="both", expand=True)
tab1 = Frame(notebook)
notebook.add(tab1,text='UnTitled')
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
sizegrip = Sizegrip(root)
sizegrip.pack(side="right", anchor=SE)
def save_as(event=None):
input_file_name = tkinter.filedialog.asksaveasfilename(defaultextension=".txt",filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt"),("HTML", "*.html"),("CSS", "*.css"),("JavaScript", "*.js")])
if input_file_name:
global file_name
file_name = input_file_name
write_to_file(file_name)
root.title('{} - {}'.format(os.path.basename(file_name), title_))
notebook.add(tab1,text=os.path.basename(file_name))
return "break"
def save(event=None):
global file_name
if not file_name:
save_as()
else:
write_to_file(file_name)
return "break"
shortcut_bar=Frame(tab1, height=25)
shortcut_bar.pack(expand='no', fill='x')
line_number_bar = Text(tab1, width=5, padx=3, takefocus=0, fg='white', border=0, background='#282828', state='disabled', wrap='none')
line_number_bar.pack(side='left', fill='y')
content_text = Text(tab1, wrap='word')
content_text.pack(expand='yes', fill='both')
scroll_bar = Scrollbar(content_text)
content_text.configure(yscrollcommand=scroll_bar.set)
scroll_bar.config(command=content_text.yview)
scroll_bar.pack(side='right', fill='y')
cursor_info_bar = Label(content_text, text='Line: 1 | Column: 1',foreground='black',background="white")
cursor_info_bar.pack(expand='no', fill=None, side='right', anchor='se')
popup_menu = Menu(content_text,tearoff=0)
popup_menu.add_command(label="Undo",accelerator='Ctrl+Z',underline=1,command=undo)
popup_menu.add_command(label="Redo",accelerator='Ctrl+Y',underline=2,command=redo)
popup_menu.add_separator()
popup_menu.add_command(label="Cut",accelerator='Ctrl+X',underline=3,command=cut)
popup_menu.add_command(label="Copy",accelerator='Ctrl+C',foreground="lightgreen",underline=4,command=copy)
popup_menu.add_command(label="Paste",accelerator='Ctrl+V',foreground="lightgreen",underline=5,command=paste)
popup_menu.add_separator()
popup_menu.add_command(label="Reload",accelerator='Ctrl+R',underline=6,command=reload)
popup_menu.add_command(label="Delete",accelerator='Delete',underline=7,command=delete)
popup_menu.add_separator()
popup_menu.add_command(label='Select All', accelerator='Ctrl+A',underline=8, command=selectall)
popup_menu.add_separator()
popup_menu.add_command(label="Exit",accelerator='Alt+F4',command=root.destroy)
root.bind('<Button-3>', show_popup_menu)
root.bind('<Control-N>', new_file)
root.bind('<Control-n>', new_file)
root.bind('<Control-O>', open_file)
root.bind('<Control-o>', open_file)
root.bind('<Control-S>', save)
root.bind('<Control-s>', save)
root.bind('<Control-Y>',redo)
root.bind('<Control-y>',redo)
root.bind('<Control-A>',selectall)
root.bind('<Control-a>',selectall)
root.bind('<Control-F>',find_text)
root.bind('<Control-f>',find_text)
root.bind("<Control-r>",reload)
root.bind("<Control-R>",reload)
root.bind("<Control-h>",help)
root.bind("<Control-H>",help)
root.bind("<Control-f>",feedback)
root.bind("<Control-F>",feedback)
root.bind("<Control-l>",license)
root.bind("<Control-L>",license)
root.bind("<Delete>",delete)
root.bind('<Any-KeyPress>', on_content_changed)
content_text.tag_configure('active_line', background='ivory2')
root.bind('<Button-3>', show_popup_menu)
root.focus_set()
root.protocol('WM_DELETE_WINDOW', exit_editor)
global black_version,black_help
black_version = "Black-Notepad v1.0"
black_help = """
--- [ Black-Notepad ]---
Argument:
--start | start
black <FileName|FileAddress>
-v | --version
-h | --help
"""
try:
txt_i = """
Black-Notepad v1.0
(Gui)
"""
if sys.argv[1] == '--start' or sys.argv[1] == 'start' or sys.argv[1].lower() == 'start' or sys.argv[1].lower() == '--start':
file_chi = open("./Core/check_i","r").read()
if file_chi == "True" or file_chi == "True\n":
showinfo(title="Black-Notepad",message=txt_i)
file_chi = open("./Core/check_i","w")
file_chi.write("False")
file_chi.close()
else:
pass
root.mainloop()
elif sys.argv[1] == '--version' or sys.argv[1] == '--v' or sys.argv[1].lower() == '--v' or sys.argv[1] == '-v' or sys.argv[1].lower() == '-v': # Code
print(f'\n{black_version}\n')
quit()
elif sys.argv[1] == '--help' or sys.argv[1].lower() == '--help' or sys.argv[1].lower() == '--h' or sys.argv[1].lower() == '--h' or sys.argv[1] == '-h' or sys.argv[1].lower() == '-h':
print(black_help)
quit()
elif sys.argv[1] == sys.argv[1]:
try:
file = open(sys.argv[1],"r").readline()
file_ = open(sys.argv[1],"r")
file_.readlines()
file_.close()
file_name = file_.name
for i in file:
content_text.insert(END,i)
notebook.add(tab1,text=os.path.basename(file_.name))
root.mainloop()
except (Exception,FileNotFoundError,NameError,):
f = open(sys.argv[1],"w")
f.write("")
f.close()
os.mknod(sys.argv[1])
file = open(sys.argv[1],"r").readline()
file_ = open(sys.argv[1],"r")
file_.readlines()
file_.close()
file_name = file_.name
for i in file:
content_text.insert(END,i)
notebook.add(tab1,text=os.path.basename(file_.name))
root.title('{} - {}'.format(os.path.basename(file_name), title_))
root.mainloop()
else:
print(f"\n{sys.argv[1]} Not Found!\n")
print("Usage: black --help")
quit()
except (IndexError,Exception,):
print("\nUsage: black --help\n")
quit()