Skip to content

Commit

Permalink
code added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sruja10 committed Dec 23, 2023
0 parents commit bdf3188
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .idea/Notepad.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit bdf3188

Please sign in to comment.