-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 76657eb
Showing
6 changed files
with
382 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
MIT License (Modified) | ||
|
||
Copyright (c) 2024 FastDrop Gaming | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
1. The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
2. Any modifications made to the Software must be documented, including | ||
a description of the changes and the date of modification. | ||
|
||
3. The Software is provided "as is", without warranty of any kind, express or | ||
implied, including but not limited to the warranties of merchantability, | ||
fitness for a particular purpose, and noninfringement. In no event shall | ||
the authors or copyright holders be liable for any claim, damages, or other | ||
liability, whether in an action of contract, tort, or otherwise, arising from, | ||
out of, or in connection with the Software or the use or other dealings in the | ||
Software. | ||
|
||
4. For any distribution of the Software, the original author must be credited. | ||
|
||
5. This license may not be modified without prior written consent from the | ||
original author. | ||
|
||
FastDrop Gaming | ||
contact@fastdropgaming.de | ||
fastdropgaming.de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# 🎨 Text Converter Tool | ||
|
||
A simple Python tool that converts stylized characters into normal characters. This program features a user-friendly GUI that allows you to upload text files and automatically convert the characters. | ||
|
||
## 🛠️ Features | ||
|
||
- 📂 **File Upload**: Upload a `.txt` file containing normal text. | ||
- 🔄 **Character Conversion**: Replace stylized characters with normal ones. | ||
- 💾 **Save**: Save the converted file as a new `.txt`. | ||
- 🖌️ **Customizable**: Customize the stylized characters Siple within the `.py`. | ||
|
||
## 📦 Prerequisites | ||
|
||
- Python 3.x | ||
- Tkinter (usually included with the standard Python installation) | ||
|
||
## 🚀 Installation | ||
|
||
1. **Install Python**: Make sure Python 3.x is installed on your system. You can download it from the [official Python website](https://www.python.org/downloads/). | ||
|
||
2. **Clone or Download**: Clone the repository or download the ZIP file: | ||
|
||
```bash | ||
git clone https://github.com/FastDropGaming/stylized-to-normal | ||
``` | ||
|
||
3. **Navigate to the project directory**: | ||
|
||
```bash | ||
cd stylized-to-normal | ||
``` | ||
|
||
4. **Instal Dependencies**: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## 🖥️ Running the Program | ||
|
||
1. **Execute the script**: | ||
|
||
```bash | ||
python text_converter.py | ||
``` | ||
|
||
2. **Click the button**: Click on "Select File" to select a `.txt` file. | ||
|
||
3. **Save the converted file**: Choose a location and a Name to save the converted file. | ||
|
||
## 📄 Example | ||
|
||
Here’s a simple example of how the text is transformed: | ||
|
||
- **Input Text**: `ʜᴇʟʟᴏ ᴡᴏʀʟᴅ` | ||
- **Output Text**: `hello world` | ||
|
||
## 🛠️ Contributing | ||
|
||
If you would like to contribute to improving this project, feel free to make suggestions or create pull requests. | ||
|
||
## 📄 License | ||
|
||
This project is licensed under a Modified MIT License. See the [LICENSE](LICENSE) file for details. | ||
|
||
## 📷 Picture of the Program | ||
|
||
![Image](https://i.imgur.com/1N4p48h.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import tkinter as tk | ||
from tkinter import filedialog, messagebox, Toplevel | ||
from collections import Counter | ||
import os # Import os for file path handling | ||
|
||
def analyze_file(file_path): | ||
# Create counters for all characters | ||
character_frequency = Counter() | ||
|
||
try: | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
content = file.read() # Read the entire content at once | ||
|
||
# Count all characters | ||
for char in content: | ||
character_frequency[char] += 1 | ||
|
||
# Generate output | ||
output_file_path = generate_output(character_frequency) | ||
|
||
# Show success message with output file path and Open button | ||
show_success_dialog(output_file_path) | ||
|
||
except FileNotFoundError: | ||
messagebox.showerror("Error", f"The file '{file_path}' was not found.") | ||
except Exception as e: | ||
messagebox.showerror("Error", f"An error occurred: {e}") | ||
|
||
def generate_output(character_frequency): | ||
# Prepare output string | ||
output_lines = [] | ||
|
||
# Sort characters by frequency (highest to lowest) | ||
sorted_characters = character_frequency.most_common() | ||
|
||
# All characters and their counts | ||
all_chars_line = " ".join(sorted(character_frequency.keys())) # No replacement for spaces | ||
output_lines.append(all_chars_line) | ||
|
||
counts_line = " ".join(str(character_frequency[char]) for char in sorted(character_frequency.keys())) | ||
output_lines.append(counts_line) | ||
|
||
# Prepare output with sorted characters by frequency | ||
sorted_output_lines = [f"{char}: {count}" for char, count in sorted_characters] | ||
output_lines.append("\n".join(sorted_output_lines)) | ||
|
||
output_file_content = "\n".join(output_lines) | ||
|
||
# Specify the output file path | ||
output_file_path = "output.txt" | ||
|
||
# Write output to a file | ||
with open(output_file_path, 'w', encoding='utf-8') as output_file: | ||
output_file.write(output_file_content) | ||
|
||
return os.path.abspath(output_file_path) # Return the full path of the output file | ||
|
||
def close_all(success_dialog): | ||
success_dialog.destroy() # Close the success dialog | ||
root.destroy() # Close the main window | ||
|
||
def show_success_dialog(output_file_path): | ||
# Create a new top-level window for success dialog | ||
success_dialog = Toplevel() | ||
success_dialog.title("Success") | ||
success_dialog.geometry("300x110") | ||
success_dialog.configure(bg="#212121") # Set background color | ||
success_dialog.resizable(False, False) | ||
|
||
# Label to show output file path | ||
success_label = tk.Label(success_dialog, text=f"Output has been written to:\n{output_file_path}", | ||
bg="#212121", fg="white") | ||
success_label.pack(pady=10) | ||
|
||
# Create buttons with pack layout | ||
open_button = tk.Button(success_dialog, text="Open", command=lambda: open_output_file(output_file_path), | ||
bg="green", fg="white", width=10) | ||
close_button = tk.Button(success_dialog, text="Close", command=lambda: close_all(success_dialog), | ||
bg="red", fg="white", width=10) | ||
|
||
# Pack buttons side by side in a frame | ||
button_frame = tk.Frame(success_dialog, bg="#212121") # Frame to hold buttons | ||
button_frame.pack(pady=10) | ||
|
||
# Center the button frame | ||
open_button.pack(side=tk.LEFT, padx=25) | ||
close_button.pack(side=tk.RIGHT, padx=25) | ||
|
||
# Center the button frame | ||
button_frame.place(relx=0.5, rely=0.7, anchor='center') # Adjusted to center under the text | ||
|
||
def open_output_file(output_file_path): | ||
"""Open the output file in the default text editor.""" | ||
try: | ||
os.startfile(output_file_path) # For Windows | ||
except Exception as e: | ||
messagebox.showerror("Error", f"Could not open the file: {e}") | ||
|
||
def open_file(): | ||
file_path = filedialog.askopenfilename( | ||
filetypes=[ | ||
("Text Files", "*.txt"), | ||
("CSV Files", "*.csv"), | ||
("TSV Files", "*.tsv"), | ||
("JSON Files", "*.json"), | ||
("XML Files", "*.xml"), | ||
("YAML Files", "*.yaml;*.yml"), | ||
("INI Files", "*.ini"), | ||
("LOG Files", "*.log"), | ||
("Markdown Files", "*.md"), | ||
("Bash Scripts", "*.sh"), | ||
("Python Scripts", "*.py"), | ||
("Properties Files", "*.properties"), | ||
("All Files", "*.*") | ||
] | ||
) | ||
if file_path: | ||
analyze_file(file_path) | ||
|
||
# Create GUI | ||
root = tk.Tk() | ||
root.title("Character Analysis") | ||
root.geometry("200x135") # Set window size | ||
root.configure(bg="#212121") # Set background color | ||
root.resizable(False, False) | ||
|
||
# Button to open the file | ||
open_button = tk.Button(root, text="Select File", command=open_file, bg="#424242", fg="white", width=20) | ||
open_button.pack(pady=50) # Center the button in the window | ||
|
||
# Main loop of the GUI | ||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Lᴏʀᴇᴍ ɪᴘꜱᴜᴍ ᴅᴏʟᴏʀ ꜱɪᴛ ᴀᴍᴇᴛ, ᴄᴏɴꜱᴇᴛᴇᴛᴜʀ ꜱᴀᴅɪᴘꜱᴄɪɴɢ ᴇʟɪᴛʀ, ꜱᴇᴅ ᴅɪᴀᴍ ɴᴏɴᴜᴍʏ ᴇɪʀᴍᴏᴅ ᴛᴇᴍᴘᴏʀ ɪɴᴠɪᴅᴜɴᴛ ᴜᴛ ʟᴀʙᴏʀᴇ ᴇᴛ ᴅᴏʟᴏʀᴇ | ||
ᴍᴀɢɴᴀ ᴀʟɪꞯᴜʏᴀᴍ ᴇʀᴀᴛ, ꜱᴇᴅ ᴅɪᴀᴍ ᴠᴏʟᴜᴘᴛᴜᴀ. Aᴛ ᴠᴇʀᴏ ᴇᴏꜱ ᴇᴛ ᴀᴄᴄᴜꜱᴀᴍ ᴇᴛ ᴊᴜꜱᴛᴏ ᴅᴜᴏ ᴅᴏʟᴏʀᴇꜱ ᴇᴛ ᴇᴀ ʀᴇʙᴜᴍ. Sᴛᴇᴛ ᴄʟɪᴛᴀ | ||
ᴋᴀꜱᴅ ɢᴜʙᴇʀɢʀᴇɴ, ɴᴏ ꜱᴇᴀ ᴛᴀᴋɪᴍᴀᴛᴀ ꜱᴀɴᴄᴛᴜꜱ ᴇꜱᴛ Lᴏʀᴇᴍ ɪᴘꜱᴜᴍ ᴅᴏʟᴏʀ ꜱɪᴛ ᴀᴍᴇᴛ. Lᴏʀᴇᴍ ɪᴘꜱᴜᴍ ᴅᴏʟᴏʀ ꜱɪᴛ ᴀᴍᴇᴛ, | ||
ᴄᴏɴꜱᴇᴛᴇᴛᴜʀ ꜱᴀᴅɪᴘꜱᴄɪɴɢ ᴇʟɪᴛʀ, ꜱᴇᴅ ᴅɪᴀᴍ ɴᴏɴᴜᴍʏ ᴇɪʀᴍᴏᴅ ᴛᴇᴍᴘᴏʀ ɪɴᴠɪᴅᴜɴᴛ ᴜᴛ ʟᴀʙᴏʀᴇ ᴇᴛ ᴅᴏʟᴏʀᴇ ᴍᴀɢɴᴀ ᴀʟɪꞯᴜʏᴀᴍ ᴇʀᴀᴛ, | ||
ꜱᴇᴅ ᴅɪᴀᴍ ᴠᴏʟᴜᴘᴛᴜᴀ. Aᴛ ᴠᴇʀᴏ ᴇᴏꜱ ᴇᴛ ᴀᴄᴄᴜꜱᴀᴍ ᴇᴛ ᴊᴜꜱᴛᴏ ᴅᴜᴏ ᴅᴏʟᴏʀᴇꜱ ᴇᴛ ᴇᴀ ʀᴇʙᴜᴍ. Sᴛᴇᴛ ᴄʟɪᴛᴀ ᴋᴀꜱᴅ ɢᴜʙᴇʀɢʀᴇɴ, | ||
ɴᴏ ꜱᴇᴀ ᴛᴀᴋɪᴍᴀᴛᴀ ꜱᴀɴᴄᴛᴜꜱ ᴇꜱᴛ Lᴏʀᴇᴍ ɪᴘꜱᴜᴍ ᴅᴏʟᴏʀ ꜱɪᴛ ᴀᴍᴇᴛ. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# requirements.txt | ||
|
||
# No additional packages are required since Tkinter is typically included with Python. | ||
# Ensure that you have Python 3.6 or higher installed otherwise it won't work. | ||
python>=3.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import tkinter as tk | ||
from tkinter import filedialog, messagebox, Toplevel | ||
from collections import Counter | ||
import os # Import os for file path handling | ||
|
||
def analyze_file(file_path): | ||
# Create counters for all characters | ||
character_frequency = Counter() | ||
|
||
try: | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
content = file.read() # Read the entire content at once | ||
|
||
# Count all characters | ||
for char in content: | ||
character_frequency[char] += 1 | ||
|
||
# Generate output | ||
output_file_path = generate_output(character_frequency) | ||
|
||
# Show success message with output file path and Open button | ||
show_success_dialog(output_file_path) | ||
|
||
except FileNotFoundError: | ||
messagebox.showerror("Error", f"The file '{file_path}' was not found.") | ||
except Exception as e: | ||
messagebox.showerror("Error", f"An error occurred: {e}") | ||
|
||
def generate_output(character_frequency): | ||
# Ask user for output file path | ||
output_file_path = filedialog.asksaveasfilename( | ||
defaultextension=".txt", | ||
filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")], | ||
title="Save Output File" | ||
) | ||
|
||
if not output_file_path: # Check if the user cancelled the dialog | ||
return | ||
|
||
# Prepare output string | ||
output_lines = [] | ||
|
||
# Sort characters by frequency (highest to lowest) | ||
sorted_characters = character_frequency.most_common() | ||
|
||
# All characters and their counts | ||
all_chars_line = " ".join(sorted(character_frequency.keys())) # No replacement for spaces | ||
output_lines.append(all_chars_line) | ||
|
||
counts_line = " ".join(str(character_frequency[char]) for char in sorted(character_frequency.keys())) | ||
output_lines.append(counts_line) | ||
|
||
# Prepare output with sorted characters by frequency | ||
sorted_output_lines = [f"{char}: {count}" for char, count in sorted_characters] | ||
output_lines.append("\n".join(sorted_output_lines)) | ||
|
||
output_file_content = "\n".join(output_lines) | ||
|
||
# Write output to a file | ||
with open(output_file_path, 'w', encoding='utf-8') as output_file: | ||
output_file.write(output_file_content) | ||
|
||
return os.path.abspath(output_file_path) # Return the full path of the output file | ||
|
||
def close_all(success_dialog): | ||
success_dialog.destroy() # Close the success dialog | ||
root.destroy() # Close the main window | ||
|
||
def show_success_dialog(output_file_path): | ||
# Create a new top-level window for success dialog | ||
success_dialog = Toplevel() | ||
success_dialog.title("Success") | ||
success_dialog.geometry("300x110") | ||
success_dialog.configure(bg="#212121") # Set background color | ||
success_dialog.resizable(False, False) | ||
|
||
# Label to show output file path | ||
success_label = tk.Label(success_dialog, text=f"Output has been written to:\n{output_file_path}", | ||
bg="#212121", fg="white") | ||
success_label.pack(pady=10) | ||
|
||
# Create buttons with pack layout | ||
open_button = tk.Button(success_dialog, text="Open", command=lambda: open_output_file(output_file_path), | ||
bg="green", fg="white", width=10) | ||
close_button = tk.Button(success_dialog, text="Close", command=lambda: close_all(success_dialog), | ||
bg="red", fg="white", width=10) | ||
|
||
# Pack buttons side by side in a frame | ||
button_frame = tk.Frame(success_dialog, bg="#212121") # Frame to hold buttons | ||
button_frame.pack(pady=10) | ||
|
||
# Center the button frame | ||
open_button.pack(side=tk.LEFT, padx=25) | ||
close_button.pack(side=tk.RIGHT, padx=25) | ||
|
||
# Center the button frame | ||
button_frame.place(relx=0.5, rely=0.7, anchor='center') # Adjusted to center under the text | ||
|
||
def open_output_file(output_file_path): | ||
"""Open the output file in the default text editor.""" | ||
try: | ||
os.startfile(output_file_path) # For Windows | ||
except Exception as e: | ||
messagebox.showerror("Error", f"Could not open the file: {e}") | ||
|
||
def open_file(): | ||
file_path = filedialog.askopenfilename( | ||
filetypes=[ | ||
("Text Files", "*.txt"), | ||
("CSV Files", "*.csv"), | ||
("TSV Files", "*.tsv"), | ||
("JSON Files", "*.json"), | ||
("XML Files", "*.xml"), | ||
("YAML Files", "*.yaml;*.yml"), | ||
("INI Files", "*.ini"), | ||
("LOG Files", "*.log"), | ||
("Markdown Files", "*.md"), | ||
("Bash Scripts", "*.sh"), | ||
("Python Scripts", "*.py"), | ||
("Properties Files", "*.properties"), | ||
("All Files", "*.*") | ||
] | ||
) | ||
if file_path: | ||
analyze_file(file_path) | ||
|
||
# Create GUI | ||
root = tk.Tk() | ||
root.title("Character Analysis") | ||
root.geometry("200x135") # Set window size | ||
root.configure(bg="#212121") # Set background color | ||
root.resizable(False, False) | ||
|
||
# Button to open the file | ||
open_button = tk.Button(root, text="Select File", command=open_file, bg="#424242", fg="white", width=20) | ||
open_button.pack(pady=50) # Center the button in the window | ||
|
||
# Main loop of the GUI | ||
root.mainloop() |