-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbionicText.py
More file actions
74 lines (58 loc) · 2.19 KB
/
bionicText.py
File metadata and controls
74 lines (58 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import tkinter as tk
from tkinter import scrolledtext
import pyperclip
import webbrowser
import os
def format_text():
input_text = text_input.get("1.0", tk.END).strip()
output_text = ""
for word in input_text.split():
half_index = len(word) // 2
formatted_word = f"<b>{word[:half_index]}</b>{word[half_index:]} "
output_text += formatted_word
text_output.config(state=tk.NORMAL) # Enable editing
text_output.delete("1.0", tk.END) # Clear previous output
text_output.insert(tk.END, output_text) # Insert new formatted text
text_output.config(state=tk.DISABLED) # Disable editing
def copy_to_clipboard():
# Get the content from the output area
output_text = text_output.get("1.0", tk.END).strip()
# Copy the content to the clipboard
pyperclip.copy(output_text)
def export_to_html():
output_text = text_output.get("1.0", tk.END).strip()
# Create HTML content
html_content = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formatted Text</title>
</head>
<body>
<p>{output_text}</p>
</body>
</html>
"""
# Define the file name and path
file_path = os.path.expanduser("./formatted_text.html")
# Write the HTML content to a file
with open(file_path, 'w') as html_file:
html_file.write(html_content)
# Open the HTML file in the default web browser
webbrowser.open(file_path)
root = tk.Tk()
root.title("Bionic Text Editor - h3x0r-offical")
text_input = scrolledtext.ScrolledText(root, wrap=tk.WORD, width=40, height=10)
text_input.pack(padx=10, pady=10)
format_button = tk.Button(root, text="Format Text", command=format_text)
format_button.pack(pady=5)
export_button = tk.Button(root, text="Open in Browser", command=export_to_html)
export_button.pack(pady=5)
copy_button = tk.Button(root, text="Copy to Clipboard", command=copy_to_clipboard)
copy_button.pack(pady=5)
text_output = scrolledtext.ScrolledText(root, wrap=tk.WORD, width=40, height=10, state=tk.DISABLED)
text_output.pack(padx=10, pady=10)
# Application loop
root.mainloop()