Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions Notepad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import tkinter
import os
from tkinter import *
from tkinter.messagebox import *
Expand All @@ -21,16 +20,11 @@ class Notepad:
__file = None

def __init__(self,**kwargs):
#initialization

#set icon
try:
self.__root.wm_iconbitmap("Notepad.ico") #GOT TO FIX THIS ERROR (ICON)
except:
pass

#set icon
self.__icon()

#set window size (the default is 300x300)

try:
self.__thisWidth = kwargs['width']
except KeyError:
Expand Down Expand Up @@ -82,18 +76,22 @@ def __init__(self,**kwargs):
self.__thisScrollBar.config(command=self.__thisTextArea.yview)
self.__thisTextArea.config(yscrollcommand=self.__thisScrollBar.set)


def __icon(self):
icon_path = os.path.join("Python-Notepad/assets/Notepad.ico")
if os.path.exists(icon_path):
self.__root.iconbitmap(icon_path)
else:
print(f"Icon file not found: {icon_path}")

def __quitApplication(self):
self.__root.destroy()
#exit()

def __showAbout(self):
showinfo("Notepad","Created by: Ferdinand Silva (http://ferdinandsilva.com)")

def __openFile(self):


def __openFile(self):
self.__file = askopenfilename(defaultextension=".txt",filetypes=[("All Files","*.*"),("Text Documents","*.txt")])

if self.__file == "":
#no file to open
self.__file = None
Expand All @@ -109,7 +107,6 @@ def __openFile(self):

file.close()


def __newFile(self):
self.__root.title("Untitled - Notepad")
self.__file = None
Expand All @@ -129,9 +126,7 @@ def __saveFile(self):
file.write(self.__thisTextArea.get(1.0,END))
file.close()
#change the window title
self.__root.title(os.path.basename(self.__file) + " - Notepad")


self.__root.title(os.path.basename(self.__file) + " - Notepad")
else:
file = open(self.__file,"w")
file.write(self.__thisTextArea.get(1.0,END))
Expand All @@ -147,13 +142,9 @@ def __paste(self):
self.__thisTextArea.event_generate("<<Paste>>")

def run(self):

#run main application
self.__root.mainloop()




#run main application
notepad = Notepad(width=600,height=400)
notepad.run()
Expand Down
Binary file added assets/Notepad.ico
Binary file not shown.