diff --git a/.idea/Notepad.iml b/.idea/Notepad.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/.idea/Notepad.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..ea177c5 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e88cf04 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..01fae13 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..e78d29f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 1703349832330 + + + + + + + + file://$PROJECT_DIR$/main.py + 8 + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..627a22b --- /dev/null +++ b/main.py @@ -0,0 +1,45 @@ +import tkinter as tk +from tkinter import filedialog + + +def openfile(): + file_path = tk.filedialog.askopenfilename(title="Select a File") + with open(file_path, 'r') as f: + content = f.read() + text_box.delete(1.0, tk.END) + text_box.insert(tk.END, content) + + +def savefile(): + content = text_box.get(1.0, tk.END) + file_path = filedialog.asksaveasfilename(title="Save As", defaultextension=".txt", filetypes=[("Text files", "*.txt")]) + + if file_path: + with open(file_path, 'w') as file: + file.write(content) + + + +window = tk.Tk() +window.title("My Notepad") + +file_frm = tk.Frame(master=window) +file_frm.pack(fill=tk.BOTH, side=tk.LEFT, expand=True) + +editor_frm = tk.Frame(master=window) +editor_frm.pack(fill=tk.BOTH, side=tk.LEFT, expand=True) + +open_btn = tk.Button(master=file_frm, text='Open', width=10, command=openfile) +open_btn.grid(row=0, padx=10, pady=10, ipadx=5, ipady=5) + + +save_btn = tk.Button(master=file_frm, text='Save As', width=10, command=savefile) +save_btn.grid(row=1, padx=10, pady=10, ipadx=5, ipady=5) + + +text_box = tk.Text(master=editor_frm) +text_box.pack() + + +window.mainloop() +