A simple yet functional text editor with a graphical user interface. Features file operations (open, save, new), text editing with syntax highlighting colors, and keyboard shortcuts. Styled with a terminal-inspired green-on-black theme.
- Create new files
- Open existing files
- Save files
- Save as (new file name)
- Clear text with confirmation
- Word wrap enabled
- Monospace font (Courier)
- Terminal-style appearance (green on black)
- Scrollbar for long documents
- Status bar showing file operations
- Keyboard shortcuts (Ctrl+S, Ctrl+O, Ctrl+N)
- Multiple file type support (.txt, .py, etc.)
- UTF-8 encoding support
- Language: Python
- Libraries:
tkinter(standard library - all widgets)filedialog,messagebox(standard library)tk==0.1.0
- Complexity: Beginner-Intermediate
# Install dependencies
pip install -r requirements.txt
# Run the program
python main.pypython main.py- Click "π New" button
- Or press
Ctrl+N - Prompts to save current file if modified
- Click "π Open" button
- Or press
Ctrl+O - Select file from dialog
- Supports .txt, .py, and all file types
- Click "πΎ Save" button
- Or press
Ctrl+S - Saves to current file or prompts for new name
- Click "ποΈ Clear" button
- Confirmation dialog appears
- Clears all text from editor
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β [πΎ Save] [π Open] [ποΈ Clear] [π New] β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Your text here... β
β β
β β
β β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Status: Ready β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
| Shortcut | Action |
|---|---|
| Ctrl+S | Save file |
| Ctrl+O | Open file |
| Ctrl+N | New file |
| Ctrl+A | Select all |
| Ctrl+C | Copy |
| Ctrl+V | Paste |
| Ctrl+X | Cut |
| Ctrl+Z | Undo |
| Ctrl+Y | Redo |
- Background: Black (#000000)
- Text: Green (#00FF00)
- Selection Background: Red
- Selection Text: White
- Cursor: Violet
- Button Frame: Dark Gray (#34495e)
Saves current content to file. If no file is open, calls save_file_as().
Opens save dialog to save with new filename.
Opens file dialog and loads selected file content.
Clears all text after confirmation.
Creates new file, prompts to save current file if modified.
- Text Files (.txt)
- Python Files (.py)
- All Files (.)
Can be extended to support:
- Markdown (.md)
- JSON (.json)
- HTML (.html)
- CSS (.css)
- JavaScript (.js)
self.text_area = Text(
self.root,
bg="white",
fg="black",
selectbackground="blue",
selectforeground="white",
font=("Arial", 11)
)self.text_area = Text(
self.root,
bg="#1e1e1e",
fg="#d4d4d4",
selectbackground="#264f78",
selectforeground="white",
font=("Consolas", 11)
)self.text_area.config(font=("Arial", 12)) # Arial
self.text_area.config(font=("Consolas", 11)) # Consolas
self.text_area.config(font=("Monaco", 10)) # Monacoclass LineNumbers(tk.Canvas):
def __init__(self, *args, **kwargs):
tk.Canvas.__init__(self, *args, **kwargs)
self.textwidget = None
def attach(self, text_widget):
self.textwidget = text_widget
def redraw(self, *args):
self.delete("all")
i = self.textwidget.index("@0,0")
while True:
dline = self.textwidget.dlineinfo(i)
if dline is None:
break
y = dline[1]
linenum = str(i).split(".")[0]
self.create_text(2, y, anchor="nw", text=linenum)
i = self.textwidget.index("%s+1line" % i)def find_text(self):
search_term = simpledialog.askstring("Find", "Enter text to find:")
if search_term:
start_pos = '1.0'
while True:
start_pos = self.text_area.search(search_term, start_pos, END)
if not start_pos:
break
end_pos = f"{start_pos}+{len(search_term)}c"
self.text_area.tag_add("highlight", start_pos, end_pos)
start_pos = end_pos
self.text_area.tag_config("highlight", background="yellow")menubar = tk.Menu(self.root)
self.root.config(menu=menubar)
# File menu
file_menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New", command=self.new_file)
file_menu.add_command(label="Open", command=self.open_file)
file_menu.add_command(label="Save", command=self.save_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=self.root.quit)
# Edit menu
edit_menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut", command=lambda: self.text_area.event_generate("<<Cut>>"))
edit_menu.add_command(label="Copy", command=lambda: self.text_area.event_generate("<<Copy>>"))
edit_menu.add_command(label="Paste", command=lambda: self.text_area.event_generate("<<Paste>>"))- Tkinter GUI development
- File I/O operations
- Text widget manipulation
- Dialog boxes (file, message)
- Event binding and keyboard shortcuts
- Widget layout and styling
- Error handling in file operations
- Syntax highlighting for code
- Line numbers
- Find and replace
- Undo/redo functionality
- Font size adjustment
- Theme selection
- Print functionality
- Recent files list
- Auto-save
- Word count
- Spell checker
- Multiple tabs
- Split view
- Minimap
- Code folding
- Auto-completion
- Check file permissions
- Ensure disk space available
- Verify file path is valid
- Check file exists
- Verify file encoding (UTF-8 supported)
- Check file permissions
- Ensure window has focus
- Check OS-level shortcuts don't conflict
| Feature | This Notepad | Windows Notepad | VS Code |
|---|---|---|---|
| File Operations | β | β | β |
| Syntax Highlighting | β | β | β |
| Line Numbers | β | β | β |
| Find/Replace | β | β | β |
| Multiple Tabs | β | β | β |
| Lightweight | β | β | β |
| Cross-platform | β | β | β |
This project is open source and available for educational purposes.