-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoteX
More file actions
208 lines (145 loc) · 5.78 KB
/
NoteX
File metadata and controls
208 lines (145 loc) · 5.78 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
# Creating Desktop Notepad with some more features
## Import Data
from tkinter import *
from tkinter import ttk
import webbrowser
from tkinter.messagebox import showerror, showinfo, showwarning
from tkinter.colorchooser import askcolor
from tkinter import filedialog
# Display project Data
window = Tk()
window.title("***First_Tech***")
window.geometry("1366x700")
window.config(bg="white")
# max or min window
window.maxsize(1360,700)
window.minsize(1000,500)
# Functon for Open_file
def open_file():
var = filedialog.askopenfile(initialdir="/", filetypes=[
("Text files", "*.txt"),
("All files", "*.*")
], title="First_Tech")
if var:
content = var.read()
text.delete(1.0, END) # Clear existing content
text.insert(INSERT, content) # Insert file content into Text widget
var.close()
# function for asksaveas file
def ask_save_as_file():
var = filedialog.asksaveasfile(title="Save as",mode="w"
,defaultextension=".txt",
initialdir="/",
filetypes=[("Txt File","*.txt"),("Python","*.py"),
("All files","*.*")]
)
if var:
content = text.get(1.0, END) # Get content from the text area
var.write(content) # Write to file
var.close()
# funtion for save
def ask_save_as_file_name():
var = filedialog.asksaveasfilename(title="Save as",mode="w"
,defaultextension=".txt",
initialdir="/",
filetypes=[("Txt File","*.txt"),("Python","*.py"),
("All files","*.*")]
)
if var:
content = text.get(1.0, END) # Get content from the text area
var.write(content)
var.close()
# function for close
def close_window():
window.destroy()
# ✅ Create the main menu bar
main_menu = Menu(window)
window.config(menu=main_menu,bg="Blue") # Set once
# === File Menu ===
file_menu = Menu(main_menu, tearoff=0)
# sub menu for (new) via file_menu
new_sub_menu = Menu(file_menu,tearoff=0)
new_sub_menu.add_command(label="New page")
new_sub_menu.add_command(label="New window")
file_menu.add_cascade(label="New",menu=new_sub_menu)
file_menu.add_command(label="Save",command=ask_save_as_file_name)
file_menu.add_command(label="Save as",command=ask_save_as_file)
file_menu.add_command(label="Save wth Password")
file_menu.add_command(label="Open",command = open_file) # command for open file
file_menu.add_command(label="Exit",command=window.quit)
main_menu.add_cascade(label="File", menu=file_menu)
# === Edit Menu ===
edit_menu = Menu(main_menu, tearoff=0)
edit_menu.add_command(label="Cut")
edit_menu.add_command(label="Paste")
edit_menu.add_separator() # Visual separator
edit_menu.add_command(label="Find Text")
main_menu.add_cascade(label="Edit", menu=edit_menu)
# Font size menu
font_size_menu = Menu(edit_menu,tearoff = 0)
font_size_menu.add_command(label="10")
font_size_menu.add_command(label="14")
font_size_menu.add_command(label="18")
font_size_menu.add_command(label="22")
font_size_menu.add_command(label="26")
font_size_menu.add_command(label="30")
font_size_menu.add_command(label="34")
edit_menu.add_cascade(label="Font size",menu=font_size_menu)
# View Menu
view_menu = Menu(main_menu,tearoff = 0)
view_menu.add_command(label="Zoom in Ctrl + plus")
view_menu.add_command(label="Zoom out Ctrl + minus")
main_menu.add_cascade(label="View", menu= view_menu)
# About Menu
def show_info():
showinfo(title=("About us"), message=("📝 First_Tech Notepad\nVersion:" \
" 5.7.25\nDeveloper: Nitesh"))
help_menu = Menu(main_menu, tearoff = 0)
help_menu.add_command(label="About", command=show_info)
main_menu.add_cascade(label="Help",menu=help_menu)
# set links
def open_link_youtube():
webbrowser.open("https://www.youtube.com/")
def open_link_whatsapp():
webbrowser.open("https://web.whatsapp.com/") # for web desktop
def open_link_linkedin():
webbrowser.open("https://www.linkedin.com/feed/")
def open_link_snapchat():
webbrowser.open("links_menu.add_separator()")
# Links menu
links_menu = Menu(main_menu, tearoff = 0)
links_menu.add_command(label="Whatsapp",command=open_link_whatsapp)
links_menu.add_command(label="Snapchat",command=open_link_snapchat)
links_menu.add_separator()
links_menu.add_command(label="YouTube",command=open_link_youtube)
links_menu.add_separator()
links_menu.add_command(label="Linkedin",command=open_link_linkedin)
main_menu.add_cascade(label="Links", menu=links_menu)
# Text Box are
text_frame = Frame(window)
text_frame.place(x=0, y=1, width=1366, height=670)
scroll_y = Scrollbar(text_frame, orient = VERTICAL)
scroll_y.pack(side = RIGHT, fill=Y)
scroll_x = Scrollbar(text_frame,orient=HORIZONTAL)
scroll_x.pack(side = BOTTOM,fill=X)
text = Text(text_frame, font=("Times New Roman", 15),wrap=NONE,undo=TRUE,
yscrollcommand=scroll_y.set,xscrollcommand=scroll_x.set)
text.pack(fill=BOTH, expand=True)
scroll_x.config(command=text.xview)
scroll_y.config(command=text.yview)
# function for ask color
def ask_color1():
color = askcolor(title=("choose \n font Color"))
if color:
text.config(fg=color[1])
# choose color via menu bar
ask_color = Menu(main_menu,tearoff=0)
ask_color.add_command(label="Choose font color",command=ask_color1)
main_menu.add_cascade(label="Font Color",menu=ask_color)
# Night Mode
# night_mode = Menu(main_menu,tearoff = 0)
# # night_mode.add_command(label="Night Mode")
# main_menu.add_cascade(label="Night Mode",menu = night_mode)
# Image for Night Mood
night_mode = Image.open()
window.mainloop()