Skip to content

Commit fc968ff

Browse files
Implemented Python GUI Notepad Script : Issue no #284 (#297)
* Create PDF Merger and Splitter.py * Update README.md * Create readme.md * Create Python GUI Notepad.py * Create Readme.md * Update README.md
1 parent b46c12a commit fc968ff

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
4+
def save_file():
5+
file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text Files", "*.txt")])
6+
if file:
7+
with open(file, 'w') as f:
8+
f.write(text_area.get(1.0, tk.END))
9+
10+
def open_file():
11+
file = filedialog.askopenfilename(filetypes=[("Text Files", "*.txt")])
12+
if file:
13+
with open(file, 'r') as f:
14+
text_area.delete(1.0, tk.END)
15+
text_area.insert(tk.END, f.read())
16+
17+
root = tk.Tk()
18+
root.title("Notepad")
19+
text_area = tk.Text(root, wrap='word')
20+
text_area.pack(expand='yes', fill='both')
21+
22+
menu = tk.Menu(root)
23+
root.config(menu=menu)
24+
file_menu = tk.Menu(menu, tearoff=0)
25+
menu.add_cascade(label="File", menu=file_menu)
26+
file_menu.add_command(label="Open", command=open_file)
27+
file_menu.add_command(label="Save As", command=save_file)
28+
29+
root.mainloop()

Python GUI Notepad/Readme.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Python GUI Notepad
2+
3+
This Python script provides a simple graphical user interface (GUI) Notepad application that allows users to open and save text files. It is built using the `tkinter` library, which comes with Python.
4+
5+
## Features
6+
7+
- **Open Files**: Open and edit existing `.txt` files.
8+
- **Save Files**: Save the current text as a new `.txt` file.
9+
10+
## Requirements
11+
12+
Make sure you have Python installed on your machine. This script uses the built-in `tkinter` library, so no additional installations are necessary.
13+
14+
## Usage
15+
16+
### Opening Files
17+
18+
- Run the script by executing the following command:
19+
```bash
20+
python gui_notepad.py
21+
```
22+
- Click on the "File" menu and select "Open" to browse and open a .txt file.
23+
- The contents of the selected file will be loaded into the text editor for editing.
24+
25+
### Saving Files
26+
- After making edits, click on the "File" menu and select "Save As" to save your work as a new .txt file.
27+
- The file will be saved with the provided name in the location of your choice.
28+
29+
### Example
30+
1) Open an existing text file:
31+
- Click on "File" -> "Open" and select the .txt file you want to edit.
32+
2) Edit the contents in the text area.
33+
3) Save the edited text:
34+
- Click on "File" -> "Save As" to save the changes to a new or existing file.

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ More information on contributing and the general code of conduct for discussion
9595
| Planet Simulation | [Planet Simulation](https://github.com/DhanushNehru/Python-Scripts/tree/master/Planet%20Simulation) | A simulation of several planets rotating around the sun.
9696
| Playlist Exchange | [Playlist Exchange](https://github.com/DhanushNehru/Python-Scripts/tree/master/Playlist%20Exchange) | A Python script to exchange songs and playlists between Spotify and Python.
9797
| Pigeonhole Sort | [Algorithm](https://github.com/DhanushNehru/Python-Scripts/tree/master/PigeonHole) | The pigeonhole sort algorithm to sort your arrays efficiently!
98-
| PNG TO JPG CONVERTOR | [PNG-To-JPG](https://github.com/DhanushNehru/Python-Scripts/tree/master/PNG%20To%20JPG) | A PNG TO JPG IMAGE CONVERTOR.
98+
| PNG TO JPG CONVERTOR | [PNG-To-JPG](https://github.com/DhanushNehru/Python-Scripts/tree/master/PNG%20To%20JPG) | A PNG TO JPG IMAGE CONVERTOR.
99+
| Python GUI Notepad | [Python GUI Notepad](https://github.com/DhanushNehru/Python-Scripts/blob/master/PDF%20Merger%20and%20Splitter/PDF%20Merger%20and%20Splitter.py) | A Python-based GUI Notepad with essential features like saving, opening, editing text files, basic formatting, and a simple user interface for quick note-taking.
99100
| QR Code Generator | [QR Code Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20Code%20Generator) | This is generate a QR code from the provided link |
100101
| QR Code with logo | [QR code with Logo](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20with%20Logo) | QR Code Customization Feature
101102
| Random Color Generator | [Random Color Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/Random%20Color%20Generator) | A random color generator that will show you the color and values! |

0 commit comments

Comments
 (0)