PYTHON CODING
These are two powerful tools to help you learn build and package .py files into .exe files and more.
Copy this code and save it as PYTHON-MAGIC-V4.py "You can use Notepad to do this."
Navigate in the folder that you save the file in using the command prompt.
Use this command to run the file: python PYTHON-MAGIC-V4.py
This program will require a few things to be installed PYTHON being the main one.
If you need help getting started contact me [email protected]
import tkinter as tk
from tkinter import messagebox, scrolledtext, simpledialog, filedialog, colorchooser
import subprocess
import pyttsx3 # For text-to-speech
import threading
import os
import sys
import re
import keyword
import ast
class PythonPackagerApp:
DEFAULT_BG_COLOR = 'white'
DEFAULT_FG_COLOR = 'black'
DEFAULT_FONT = ('Arial', 12)
HIGHLIGHT_INTERVAL = 100 # milliseconds
def __init__(self, master):
self.master = master
self.master.title("Python Tester & Packager")
# Initialize text-to-speech
self.engine = pyttsx3.init()
# Text area for code input
self.code_area = scrolledtext.ScrolledText(master, width=80, height=20,
bg=self.DEFAULT_BG_COLOR,
fg=self.DEFAULT_FG_COLOR,
font=self.DEFAULT_FONT)
self.code_area.pack(pady=10)
# Create context menu
self.context_menu = tk.Menu(master, tearoff=0)
self.context_menu.add_command(label="Select All", command=self.select_all)
self.context_menu.add_command(label="Copy", command=self.copy_text)
self.context_menu.add_command(label="Cut", command=self.cut_text)
self.context_menu.add_command(label="Paste", command=self.paste_text)
self.context_menu.add_command(label="Delete", command=self.delete_text)
self.code_area.bind("<Button-3>", self.show_context_menu) # Right-click
# Create a menu bar
self.menubar = tk.Menu(master)
self.master.config(menu=self.menubar)
# Add "Customization" menu
customization_menu = tk.Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Customization", menu=customization_menu)
# Customization options
customization_menu.add_command(label="Change Background Color", command=self.change_background_color)
customization_menu.add_command(label="Change Text Color", command=self.change_text_color)
customization_menu.add_command(label="Change Button Color", command=self.change_button_color)
customization_menu.add_command(label="Change Text Area Background Color", command=self.change_text_area_bg_color)
customization_menu.add_command(label="Change Text Area Text Color", command=self.change_text_area_text_color)
customization_menu.add_command(label="Change Text Size", command=self.change_text_size)
# Add "Help" menu
help_menu = tk.Menu(self.menubar, tearoff=0)
help_menu.add_command(label="About", command=self.show_about)
help_menu.add_command(label="Help", command=self.show_help)
self.menubar.add_cascade(label="Help", menu=help_menu)
# Load Code Button
self.load_button = tk.Button(master, text="Load Example Code", command=self.load_code_from_file)
self.load_button.pack(pady=5)
# Run Code Button
self.run_button = tk.Button(master, text="Run Code", command=self.run_code)
self.run_button.pack(pady=5)
# Save Code Button
self.save_button = tk.Button(master, text="Save as .py", command=self.save_code)
self.save_button.pack(pady=5)
# Package as .exe Button
self.package_button = tk.Button(master, text="Package as .exe", command=self.package_exe)
self.package_button.pack(pady=5)
# Install Dependencies Button
self.install_button = tk.Button(master, text="Install Dependencies", command=self.install_dependencies)
self.install_button.pack(pady=5)
# Debug Code Button
self.debug_button = tk.Button(master, text="Debug Code", command=self.debug_code)
self.debug_button.pack(pady=5)
# Create Project Button
self.create_project_button = tk.Button(master, text="Create Project", command=self.create_project)
self.create_project_button.pack(pady=5)
# Open Project Button
self.open_project_button = tk.Button(master, text="Open Project", command=self.open_project)
self.open_project_button.pack(pady=5)
# Sample code explanations
self.explain_functionality()
# Syntax highlighting
self.syntax_highlighting()
def show_context_menu(self, event):
"""Show the context menu on right-click."""
self.context_menu.post(event.x_root, event.y_root)
def select_all(self):
"""Select all text in the code area."""
self.code_area.tag_add("sel", "1.0", "end")
self.speak("Selected all text.")
def copy_text(self):
"""Copy selected text to clipboard."""
self.master.clipboard_clear()
text = self.code_area.get("sel.first", "sel.last")
self.master.clipboard_append(text)
self.speak("Copied selected text.")
def cut_text(self):
"""Cut selected text from the code area."""
self.copy_text()
self.code_area.delete("sel.first", "sel.last")
self.speak("Cut selected text.")
def paste_text(self):
"""Paste text from clipboard into the code area."""
try:
text = self.master.clipboard_get()
self.code_area.insert(tk.INSERT, text)
self.speak("Pasted text.")
except tk.TclError:
messagebox.showwarning("Warning", "No text found in clipboard.")
def delete_text(self):
"""Delete selected text from the code area."""
try:
self.code_area.delete("sel.first", "sel.last")
self.speak("Deleted selected text.")
except tk.TclError:
messagebox.showwarning("Warning", "No text selected to delete.")
def load_code_from_file(self):
"""Load example code from a file."""
file_path = filedialog.askopenfilename(title="Select a Python File", filetypes=[("Python Files", "*.py")])
if file_path:
try:
with open(file_path, 'r') as code_file:
code_content = code_file.read()
self.code_area.delete("1.0", tk.END) # Clear existing content
self.code_area.insert(tk.END, code_content) # Insert new content
self.speak("Loaded code from file.")
except Exception as e:
messagebox.showerror("Error", f"Failed to load code: {e}")
def run_code(self):
"""Run the code in a separate thread."""
threading.Thread(target=self.execute_code).start()
def execute_code(self):
"""Execute the code."""
code = self.code_area.get("1.0", tk.END)
try:
exec(code)
except Exception as e:
messagebox.showerror("Error", str(e))
def save_code(self):
"""Save the code as a .py file."""
filename = simpledialog.askstring("Save Code", "Enter filename (without extension):")
if filename:
with open(f"{filename}.py", "w") as code_file:
code_file.write(self.code_area.get("1.0", tk.END))
messagebox.showinfo("Saved", f"Code saved as {filename}.py")
self.speak(f"Saved the file as {filename}.py.")
def package_exe(self):
"""Package the code as an executable."""
filename = simpledialog.askstring("Package Code", "Enter filename (without extension) for .exe:")
if filename:
py_file = f"{filename}.py"
with open(py_file, "w") as code_file:
code_file.write(self.code_area.get("1.0", tk.END))
# Run PyInstaller to create executable
try:
subprocess.run(['pyinstaller', '--onefile', py_file], check=True)
messagebox.showinfo("Success", f"Executable created in the 'dist' folder.")
self.speak(f"Executable created as {filename}.exe.")
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", "Failed to package the .exe file.")
def install_dependencies(self):
"""Install dependencies."""
try:
subprocess.run(['pip', 'install', 'pyinstaller'], check=True)
messagebox.showinfo("Success", "Dependencies installed successfully.")
self.speak("Installed dependencies successfully.")
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", "Failed to install dependencies.")
def debug_code(self):
"""Debug the code."""
code = self.code_area.get("1.0", tk.END)
try:
ast.parse(code)
messagebox.showinfo("Success", "Code is valid.")
except SyntaxError as e:
messagebox.showerror("Error", f"Invalid syntax: {e}")
def create_project(self):
"""Create a new project."""
project_name = simpledialog.askstring("Create Project", "Enter project name:")
if project_name:
try:
os.mkdir(project_name)
messagebox.showinfo("Success", f"Project '{project_name}' created.")
self.speak(f"Project '{project_name}' created.")
except Exception as e:
messagebox.showerror("Error", f"Failed to create project: {e}")
def open_project(self):
"""Open an existing project."""
project_path = filedialog.askdirectory(title="Select a Project Directory")
if project_path:
try:
os.chdir(project_path)
messagebox.showinfo("Success", f"Project opened: {project_path}")
self.speak(f"Project opened: {project_path}")
except Exception as e:
messagebox.showerror("Error", f"Failed to open project: {e}")
def change_background_color(self):
"""Change the background color of the main window."""
color = colorchooser.askcolor()[1]
if color:
self.master.config(bg=color)
def change_text_color(self):
"""Change the text color in the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(fg=color)
def change_button_color(self):
"""Change the color of all buttons."""
color = colorchooser.askcolor()[1]
if color:
for button in [self.load_button, self.run_button, self.save_button,
self.package_button, self.install_button,
self.debug_button, self.create_project_button,
self.open_project_button]:
button.config(bg=color)
def change_text_area_bg_color(self):
"""Change the background color of the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(bg=color)
def change_text_area_text_color(self):
"""Change the text color of the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(fg=color)
def change_text_size(self):
"""Change the text size in the code area."""
size = simpledialog.askinteger("Text Size", "Enter text size:", initialvalue=12)
if size:
self.code_area.config(font=('Arial', size))
def speak(self, text):
"""Convert text to speech."""
self.engine.say(text)
self.engine.runAndWait()
def explain_functionality(self):
"""Provide text-to-speech explanations for functionalities."""
explanations = [
"This application allows you to write, test, and package Python code.",
"You can run your code to see the output.",
"You can save your code as a Python file.",
"You can package your code into an executable file.",
"Right-click to access options to select all, copy, cut, paste, and delete text."
]
for explanation in explanations:
self.speak(explanation)
def show_about(self):
"""Show about information."""
messagebox.showinfo("About", "Python Tester & Packager\n\nDeveloped by Shazizz\nEmail: [email protected]\nVisit: https://www.shazizz.net")
def show_help(self):
"""Show help information."""
messagebox.showinfo("Help", "Use this application to write and test Python code, save it as a .py file, or package it as an .exe.\n\nFor further assistance, contact: [email protected]")
def syntax_highlighting(self):
"""Highlight Python syntax."""
self.code_area.tag_config('keyword', foreground='blue')
self.code_area.tag_config('string', foreground='green')
self.code_area.tag_config('comment', foreground='red')
keywords = keyword.kwlist
strings = ['\'', '\"']
comments = ['#']
def highlight_syntax():
self.code_area.tag_remove('keyword', '1.0', 'end')
self.code_area.tag_remove('string', '1.0', 'end')
self.code_area.tag_remove('comment', '1.0', 'end')
for keyword in keywords:
start_index = '1.0'
while True:
start_index = self.code_area.search(keyword, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+{len(keyword)}c'
self.code_area.tag_add('keyword', start_index, last_index)
start_index = last_index
for string in strings:
start_index = '1.0'
while True:
start_index = self.code_area.search(string, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+1c'
self.code_area.tag_add('string', start_index, last_index)
start_index = last_index
for comment in comments:
start_index = '1.0'
while True:
start_index = self.code_area.search(comment, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+1c'
self.code_area.tag_add('comment', start_index, 'end')
start_index = last_index
self.master.after(self.HIGHLIGHT_INTERVAL, highlight_syntax)
if __name__ == "__main__":
root = tk.Tk()
app = PythonPackagerApp(root)
root.mainloop()
Navigate in the folder that you save the file in using the command prompt.
Use this command to run the file: python PYTHON-MAGIC-V4.py
This program will require a few things to be installed PYTHON being the main one.
If you need help getting started contact me [email protected]
import tkinter as tk
from tkinter import messagebox, scrolledtext, simpledialog, filedialog, colorchooser
import subprocess
import pyttsx3 # For text-to-speech
import threading
import os
import sys
import re
import keyword
import ast
class PythonPackagerApp:
DEFAULT_BG_COLOR = 'white'
DEFAULT_FG_COLOR = 'black'
DEFAULT_FONT = ('Arial', 12)
HIGHLIGHT_INTERVAL = 100 # milliseconds
def __init__(self, master):
self.master = master
self.master.title("Python Tester & Packager")
# Initialize text-to-speech
self.engine = pyttsx3.init()
# Text area for code input
self.code_area = scrolledtext.ScrolledText(master, width=80, height=20,
bg=self.DEFAULT_BG_COLOR,
fg=self.DEFAULT_FG_COLOR,
font=self.DEFAULT_FONT)
self.code_area.pack(pady=10)
# Create context menu
self.context_menu = tk.Menu(master, tearoff=0)
self.context_menu.add_command(label="Select All", command=self.select_all)
self.context_menu.add_command(label="Copy", command=self.copy_text)
self.context_menu.add_command(label="Cut", command=self.cut_text)
self.context_menu.add_command(label="Paste", command=self.paste_text)
self.context_menu.add_command(label="Delete", command=self.delete_text)
self.code_area.bind("<Button-3>", self.show_context_menu) # Right-click
# Create a menu bar
self.menubar = tk.Menu(master)
self.master.config(menu=self.menubar)
# Add "Customization" menu
customization_menu = tk.Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Customization", menu=customization_menu)
# Customization options
customization_menu.add_command(label="Change Background Color", command=self.change_background_color)
customization_menu.add_command(label="Change Text Color", command=self.change_text_color)
customization_menu.add_command(label="Change Button Color", command=self.change_button_color)
customization_menu.add_command(label="Change Text Area Background Color", command=self.change_text_area_bg_color)
customization_menu.add_command(label="Change Text Area Text Color", command=self.change_text_area_text_color)
customization_menu.add_command(label="Change Text Size", command=self.change_text_size)
# Add "Help" menu
help_menu = tk.Menu(self.menubar, tearoff=0)
help_menu.add_command(label="About", command=self.show_about)
help_menu.add_command(label="Help", command=self.show_help)
self.menubar.add_cascade(label="Help", menu=help_menu)
# Load Code Button
self.load_button = tk.Button(master, text="Load Example Code", command=self.load_code_from_file)
self.load_button.pack(pady=5)
# Run Code Button
self.run_button = tk.Button(master, text="Run Code", command=self.run_code)
self.run_button.pack(pady=5)
# Save Code Button
self.save_button = tk.Button(master, text="Save as .py", command=self.save_code)
self.save_button.pack(pady=5)
# Package as .exe Button
self.package_button = tk.Button(master, text="Package as .exe", command=self.package_exe)
self.package_button.pack(pady=5)
# Install Dependencies Button
self.install_button = tk.Button(master, text="Install Dependencies", command=self.install_dependencies)
self.install_button.pack(pady=5)
# Debug Code Button
self.debug_button = tk.Button(master, text="Debug Code", command=self.debug_code)
self.debug_button.pack(pady=5)
# Create Project Button
self.create_project_button = tk.Button(master, text="Create Project", command=self.create_project)
self.create_project_button.pack(pady=5)
# Open Project Button
self.open_project_button = tk.Button(master, text="Open Project", command=self.open_project)
self.open_project_button.pack(pady=5)
# Sample code explanations
self.explain_functionality()
# Syntax highlighting
self.syntax_highlighting()
def show_context_menu(self, event):
"""Show the context menu on right-click."""
self.context_menu.post(event.x_root, event.y_root)
def select_all(self):
"""Select all text in the code area."""
self.code_area.tag_add("sel", "1.0", "end")
self.speak("Selected all text.")
def copy_text(self):
"""Copy selected text to clipboard."""
self.master.clipboard_clear()
text = self.code_area.get("sel.first", "sel.last")
self.master.clipboard_append(text)
self.speak("Copied selected text.")
def cut_text(self):
"""Cut selected text from the code area."""
self.copy_text()
self.code_area.delete("sel.first", "sel.last")
self.speak("Cut selected text.")
def paste_text(self):
"""Paste text from clipboard into the code area."""
try:
text = self.master.clipboard_get()
self.code_area.insert(tk.INSERT, text)
self.speak("Pasted text.")
except tk.TclError:
messagebox.showwarning("Warning", "No text found in clipboard.")
def delete_text(self):
"""Delete selected text from the code area."""
try:
self.code_area.delete("sel.first", "sel.last")
self.speak("Deleted selected text.")
except tk.TclError:
messagebox.showwarning("Warning", "No text selected to delete.")
def load_code_from_file(self):
"""Load example code from a file."""
file_path = filedialog.askopenfilename(title="Select a Python File", filetypes=[("Python Files", "*.py")])
if file_path:
try:
with open(file_path, 'r') as code_file:
code_content = code_file.read()
self.code_area.delete("1.0", tk.END) # Clear existing content
self.code_area.insert(tk.END, code_content) # Insert new content
self.speak("Loaded code from file.")
except Exception as e:
messagebox.showerror("Error", f"Failed to load code: {e}")
def run_code(self):
"""Run the code in a separate thread."""
threading.Thread(target=self.execute_code).start()
def execute_code(self):
"""Execute the code."""
code = self.code_area.get("1.0", tk.END)
try:
exec(code)
except Exception as e:
messagebox.showerror("Error", str(e))
def save_code(self):
"""Save the code as a .py file."""
filename = simpledialog.askstring("Save Code", "Enter filename (without extension):")
if filename:
with open(f"{filename}.py", "w") as code_file:
code_file.write(self.code_area.get("1.0", tk.END))
messagebox.showinfo("Saved", f"Code saved as {filename}.py")
self.speak(f"Saved the file as {filename}.py.")
def package_exe(self):
"""Package the code as an executable."""
filename = simpledialog.askstring("Package Code", "Enter filename (without extension) for .exe:")
if filename:
py_file = f"{filename}.py"
with open(py_file, "w") as code_file:
code_file.write(self.code_area.get("1.0", tk.END))
# Run PyInstaller to create executable
try:
subprocess.run(['pyinstaller', '--onefile', py_file], check=True)
messagebox.showinfo("Success", f"Executable created in the 'dist' folder.")
self.speak(f"Executable created as {filename}.exe.")
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", "Failed to package the .exe file.")
def install_dependencies(self):
"""Install dependencies."""
try:
subprocess.run(['pip', 'install', 'pyinstaller'], check=True)
messagebox.showinfo("Success", "Dependencies installed successfully.")
self.speak("Installed dependencies successfully.")
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", "Failed to install dependencies.")
def debug_code(self):
"""Debug the code."""
code = self.code_area.get("1.0", tk.END)
try:
ast.parse(code)
messagebox.showinfo("Success", "Code is valid.")
except SyntaxError as e:
messagebox.showerror("Error", f"Invalid syntax: {e}")
def create_project(self):
"""Create a new project."""
project_name = simpledialog.askstring("Create Project", "Enter project name:")
if project_name:
try:
os.mkdir(project_name)
messagebox.showinfo("Success", f"Project '{project_name}' created.")
self.speak(f"Project '{project_name}' created.")
except Exception as e:
messagebox.showerror("Error", f"Failed to create project: {e}")
def open_project(self):
"""Open an existing project."""
project_path = filedialog.askdirectory(title="Select a Project Directory")
if project_path:
try:
os.chdir(project_path)
messagebox.showinfo("Success", f"Project opened: {project_path}")
self.speak(f"Project opened: {project_path}")
except Exception as e:
messagebox.showerror("Error", f"Failed to open project: {e}")
def change_background_color(self):
"""Change the background color of the main window."""
color = colorchooser.askcolor()[1]
if color:
self.master.config(bg=color)
def change_text_color(self):
"""Change the text color in the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(fg=color)
def change_button_color(self):
"""Change the color of all buttons."""
color = colorchooser.askcolor()[1]
if color:
for button in [self.load_button, self.run_button, self.save_button,
self.package_button, self.install_button,
self.debug_button, self.create_project_button,
self.open_project_button]:
button.config(bg=color)
def change_text_area_bg_color(self):
"""Change the background color of the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(bg=color)
def change_text_area_text_color(self):
"""Change the text color of the code area."""
color = colorchooser.askcolor()[1]
if color:
self.code_area.config(fg=color)
def change_text_size(self):
"""Change the text size in the code area."""
size = simpledialog.askinteger("Text Size", "Enter text size:", initialvalue=12)
if size:
self.code_area.config(font=('Arial', size))
def speak(self, text):
"""Convert text to speech."""
self.engine.say(text)
self.engine.runAndWait()
def explain_functionality(self):
"""Provide text-to-speech explanations for functionalities."""
explanations = [
"This application allows you to write, test, and package Python code.",
"You can run your code to see the output.",
"You can save your code as a Python file.",
"You can package your code into an executable file.",
"Right-click to access options to select all, copy, cut, paste, and delete text."
]
for explanation in explanations:
self.speak(explanation)
def show_about(self):
"""Show about information."""
messagebox.showinfo("About", "Python Tester & Packager\n\nDeveloped by Shazizz\nEmail: [email protected]\nVisit: https://www.shazizz.net")
def show_help(self):
"""Show help information."""
messagebox.showinfo("Help", "Use this application to write and test Python code, save it as a .py file, or package it as an .exe.\n\nFor further assistance, contact: [email protected]")
def syntax_highlighting(self):
"""Highlight Python syntax."""
self.code_area.tag_config('keyword', foreground='blue')
self.code_area.tag_config('string', foreground='green')
self.code_area.tag_config('comment', foreground='red')
keywords = keyword.kwlist
strings = ['\'', '\"']
comments = ['#']
def highlight_syntax():
self.code_area.tag_remove('keyword', '1.0', 'end')
self.code_area.tag_remove('string', '1.0', 'end')
self.code_area.tag_remove('comment', '1.0', 'end')
for keyword in keywords:
start_index = '1.0'
while True:
start_index = self.code_area.search(keyword, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+{len(keyword)}c'
self.code_area.tag_add('keyword', start_index, last_index)
start_index = last_index
for string in strings:
start_index = '1.0'
while True:
start_index = self.code_area.search(string, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+1c'
self.code_area.tag_add('string', start_index, last_index)
start_index = last_index
for comment in comments:
start_index = '1.0'
while True:
start_index = self.code_area.search(comment, start_index, stopindex='end')
if not start_index:
break
last_index = f'{start_index}+1c'
self.code_area.tag_add('comment', start_index, 'end')
start_index = last_index
self.master.after(self.HIGHLIGHT_INTERVAL, highlight_syntax)
if __name__ == "__main__":
root = tk.Tk()
app = PythonPackagerApp(root)
root.mainloop()
Copy this code and save it as PYTHON-MAGIC-V4.py "You can use Notepad to do this."
Navigate in the folder that you save the file in using the command prompt.
Use this command to run the file: python multi_task_coder.py
This program will require a few things to be installed PYTHON being the main one.
If you need help getting started contact me [email protected]
import tkinter as tk
from tkinter import filedialog, messagebox, simpledialog, colorchooser, Menu, Toplevel
import pyttsx3
import os
import zipfile
import subprocess
import webbrowser
class MultiTaskCoderApp:
def __init__(self, master):
self.master = master
master.title("SHAZIZZ Multi-Task Coding Tool")
# Set the default colors
self.bg_color = 'black'
self.text_color = 'lime'
self.button_color = 'red'
self.frame_color = 'black'
# Set the background color of the main window
master.configure(bg=self.bg_color)
# Text editor configuration
self.text_editor = tk.Text(master, wrap='word', undo=True, bg=self.bg_color, fg=self.text_color, insertbackground=self.text_color)
self.text_editor.pack(expand=1, fill='both')
self.toolbar = tk.Frame(master, bg=self.frame_color)
self.toolbar.pack(side='top', fill='x')
# Style for buttons
button_style = {
'bg': self.button_color,
'fg': 'white',
'activebackground': 'darkred',
'activeforeground': 'white',
'highlightthickness': 0
}
# Create a menu bar
self.menu_bar = Menu(master)
master.config(menu=self.menu_bar)
# Help Menu
self.help_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Help", menu=self.help_menu)
self.help_menu.add_command(label="About", command=self.show_about)
self.help_menu.add_command(label="Load Help File", command=self.load_help_file)
self.help_menu.add_command(label="Visit SHAZIZZ", command=self.visit_shazizz)
# Sample Code Menu
self.sample_code_menu = Menu(self.help_menu, tearoff=0)
self.menu_bar.add_cascade(label="Sample Code", menu=self.sample_code_menu)
self.sample_code_menu.add_command(label="Basic HTML Structure", command=self.insert_basic_html_structure)
self.sample_code_menu.add_command(label="Image Tag", command=self.insert_image_tag)
self.sample_code_menu.add_command(label="Link Tag", command=self.insert_link_tag)
self.sample_code_menu.add_command(label="Audio Tag", command=self.insert_audio_tag)
self.sample_code_menu.add_command(label="Video Tag", command=self.insert_video_tag)
# New entries for <center> and <p>
self.sample_code_menu.add_command(label="<center></center>", command=self.insert_center_tag)
self.sample_code_menu.add_command(label="<p></p>", command=self.insert_paragraph_tag)
self.sample_code_menu.add_command(label="Load Example.txt", command=self.load_example_file)
# Customize Menu
self.customize_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Customize the Look", menu=self.customize_menu)
self.customize_menu.add_command(label="Background Color", command=self.change_background_color)
self.customize_menu.add_command(label="Text Color", command=self.change_text_color)
self.customize_menu.add_command(label="Frame Color", command=self.change_frame_color)
self.customize_menu.add_command(label="Button Color", command=self.change_button_color)
# Command Prompt Menu
self.command_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Command Prompt", menu=self.command_menu)
self.command_menu.add_command(label="Open New Command Prompt", command=self.open_command_prompt)
# Add buttons to the toolbar
self.undo_button = tk.Button(self.toolbar, text="Undo", command=self.undo, **button_style)
self.undo_button.pack(side='left')
self.redo_button = tk.Button(self.toolbar, text="Redo", command=self.redo, **button_style)
self.redo_button.pack(side='left')
self.insert_image_button = tk.Button(self.toolbar, text="Insert Image", command=self.insert_image, **button_style)
self.insert_image_button.pack(side='left')
self.color_button = tk.Button(self.toolbar, text="Text Color", command=self.choose_text_color, **button_style)
self.color_button.pack(side='left')
self.size_button = tk.Button(self.toolbar, text="Text Size", command=self.choose_text_size, **button_style)
self.size_button.pack(side='left')
self.bg_color_button = tk.Button(self.toolbar, text="Background Color", command=self.choose_background_color, **button_style)
self.bg_color_button.pack(side='left')
self.title_button = tk.Button(self.toolbar, text="Add Title", command=self.add_title, **button_style)
self.title_button.pack(side='left')
self.voice_html_button = tk.Button(self.toolbar, text="Add Audio File", command=self.add_voice_to_html, **button_style)
self.voice_html_button.pack(side='left')
self.textbox_button = tk.Button(self.toolbar, text="Add Text Box", command=self.add_text_box, **button_style)
self.textbox_button.pack(side='left')
self.button_button = tk.Button(self.toolbar, text="Add Button", command=self.add_button, **button_style)
self.button_button.pack(side='left')
self.hyperlink_button = tk.Button(self.toolbar, text="Add Hyperlink", command=self.add_hyperlink, **button_style)
self.hyperlink_button.pack(side='left')
self.video_button = tk.Button(self.toolbar, text="Insert Video", command=self.insert_video, **button_style)
self.video_button.pack(side='left')
self.header_button = tk.Button(self.toolbar, text="Add Header", command=self.add_header, **button_style)
self.header_button.pack(side='left')
self.custom_script_button = tk.Button(self.toolbar, text="Custom Script", command=self.add_custom_script, **button_style)
self.custom_script_button.pack(side='left')
self.test_button = tk.Button(self.toolbar, text="Test in Browser", command=self.test_in_browser, **button_style)
self.test_button.pack(side='left')
self.save_button = tk.Button(master, text="Save as...", command=self.save_file, **button_style)
self.save_button.pack(side='left')
self.open_button = tk.Button(master, text="Open...", command=self.open_file, **button_style)
self.open_button.pack(side='left')
self.new_project_button = tk.Button(master, text="New Project", command=self.new_project, **button_style)
self.new_project_button.pack(side='left')
self.tutorial_button = tk.Button(master, text="Read Tutorial", command=self.read_tutorial, **button_style)
self.tutorial_button.pack(side='left')
self.zip_button = tk.Button(master, text="Zip Files", command=self.zip_files, **button_style)
self.zip_button.pack(side='left')
self.launch_app_button = tk.Button(master, text="Launch Notepad", command=self.launch_notepad, **button_style)
self.launch_app_button.pack(side='left')
self.engine = pyttsx3.init()
self.current_file = None # To keep track of the current file
# Right-click context menu
self.context_menu = Menu(master, tearoff=0)
self.context_menu.add_command(label="Select All", command=self.select_all)
self.context_menu.add_command(label="Cut", command=self.cut)
self.context_menu.add_command(label="Copy", command=self.copy)
self.context_menu.add_command(label="Paste", command=self.paste)
self.context_menu.add_command(label="Delete", command=self.delete)
# Bind the right-click event
self.text_editor.bind("<Button-3>", self.show_context_menu)
# Bind the close event to ask for saving changes
master.protocol("WM_DELETE_WINDOW", self.on_exit)
def select_all(self):
self.text_editor.tag_add("sel", "1.0", "end")
def load_help_file(self):
help_file_path = 'help.txt' # Ensure this file exists in the same directory
if os.path.exists(help_file_path):
with open(help_file_path, 'r') as file:
content = file.read()
# Create a new top-level window to display the help content
help_window = Toplevel(self.master)
help_window.title("Help")
help_text = tk.Text(help_window, wrap='word')
help_text.insert(tk.END, content)
help_text.pack(expand=1, fill='both')
help_text.config(state=tk.DISABLED) # Make it read-only
else:
messagebox.showerror("Error", "help.txt not found!")
def visit_shazizz(self):
webbrowser.open("https://www.shazizz.net")
def open_command_prompt(self):
subprocess.Popen("start cmd", shell=True)
def insert_center_tag(self):
self.text_editor.insert(tk.END, "<center></center>\n")
def insert_paragraph_tag(self):
self.text_editor.insert(tk.END, "<p></p>\n")
def load_example_file(self):
example_file_path = 'example.txt' # Ensure this file exists in the same directory
if os.path.exists(example_file_path):
with open(example_file_path, 'r') as file:
content = file.read()
self.text_editor.delete("1.0", tk.END) # Clear the editor before loading
self.text_editor.insert(tk.END, content)
else:
messagebox.showerror("Error", "example.txt not found!")
def show_context_menu(self, event):
self.context_menu.post(event.x_root, event.y_root)
def cut(self):
self.text_editor.event_generate("<<Cut>>")
def copy(self):
self.text_editor.event_generate("<<Copy>>")
def paste(self):
self.text_editor.event_generate("<<Paste>>")
def delete(self):
self.text_editor.delete("sel.first", "sel.last")
def change_background_color(self):
color = colorchooser.askcolor()[1]
if color:
self.bg_color = color
self.master.configure(bg=self.bg_color)
self.text_editor.config(bg=self.bg_color)
def change_text_color(self):
color = colorchooser.askcolor()[1]
if color:
self.text_color = color
self.text_editor.config(fg=self.text_color, insertbackground=self.text_color)
def change_frame_color(self):
color = colorchooser.askcolor()[1]
if color:
self.frame_color = color
self.toolbar.config(bg=self.frame_color)
def change_button_color(self):
color = colorchooser.askcolor()[1]
if color:
self.button_color = color
for widget in self.toolbar.winfo_children():
widget.config(bg=self.button_color)
def add_custom_script(self):
custom_script = simpledialog.askstring("Custom Script", "Enter your custom script:")
if custom_script:
self.text_editor.insert(tk.END, f"<script>\n{custom_script}\n</script>\n")
def insert_basic_html_structure(self):
html_code = """<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
"""
self.text_editor.insert(tk.END, html_code)
def insert_image_tag(self):
html_code = '<img src="image_url.jpg" alt="Image Description" />\n'
self.text_editor.insert(tk.END, html_code)
def insert_link_tag(self):
html_code = '<a href="http://example.com">This is a link</a>\n'
self.text_editor.insert(tk.END, html_code)
def insert_audio_tag(self):
html_code = """<audio controls>
<source src="audio_file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
"""
self.text_editor.insert(tk.END, html_code)
def insert_video_tag(self):
html_code = """<video width="320" height="240" controls>
<source src="video_file.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
"""
self.text_editor.insert(tk.END, html_code)
def insert_image(self):
# Open a file dialog to select an image
img_path = filedialog.askopenfilename(filetypes=[("Image files", ("*.jpg", "*.jpeg", "*.png", "*.gif"))])
if img_path:
# Insert the HTML img tag into the text editor
img_tag = f'<img src="{img_path}" alt="Image" />\n'
self.text_editor.insert(tk.END, img_tag)
def undo(self):
self.text_editor.edit_undo()
def redo(self):
self.text_editor.edit_redo()
def choose_text_color(self):
color = colorchooser.askcolor()[1]
if color:
html_code = f'<span style="color:{color};">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</span>\n') # Closing tag for span
def choose_text_size(self):
size = simpledialog.askinteger("Text Size", "Enter text size:", minvalue=1, maxvalue=100)
if size:
html_code = f'<span style="font-size:{size}px;">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</span>\n') # Closing tag for span
def choose_background_color(self):
color = colorchooser.askcolor()[1]
if color:
html_code = f'<div style="background-color:{color};">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</div>\n') # Closing tag for div
def add_title(self):
title = simpledialog.askstring("Title", "Enter the title:")
if title:
self.text_editor.insert(tk.END, f"<title>{title}</title>\n")
def add_voice_to_html(self):
html_code = simpledialog.askstring("Add Audio File", "Enter Url to Audio File:")
if html_code:
self.text_editor.insert(tk.END, f"<audio controls>\n<source src='{html_code}' type='audio/mpeg'>\nYour browser does not support the audio element.\n</audio>\n")
def add_text_box(self):
self.text_editor.insert(tk.END, "<input type='text' placeholder='Your text here'>\n")
def add_button(self):
button_text = simpledialog.askstring("Button", "Enter button text:")
if button_text:
self.text_editor.insert(tk.END, f"<button>{button_text}</button>\n")
def add_hyperlink(self):
link_text = simpledialog.askstring("Hyperlink", "Enter link text:")
url = simpledialog.askstring("Hyperlink", "Enter URL:")
if link_text and url:
self.text_editor.insert(tk.END, f"<a href='{url}'>{link_text}</a>\n")
def insert_video(self):
video_url = simpledialog.askstring("Insert Video", "Enter video URL:")
if video_url:
self.text_editor.insert(tk.END, f"<video width='320' height='240' controls>\n<source src='{video_url}' type='video/mp4'>\nYour browser does not support the video tag.\n</video>\n")
def add_header(self):
header_text = simpledialog.askstring("Header", "Enter header text:")
if header_text:
self.text_editor.insert(tk.END, f"<h1>{header_text}</h1>\n")
def test_in_browser(self):
html_content = self.text_editor.get("1.0", tk.END)
with open("temp_test.html", "w") as file:
file.write(html_content)
webbrowser.open("temp_test.html")
def save_file(self):
file_path = filedialog.asksaveasfilename(defaultextension=".txt",
filetypes=[("Text files", "*.txt"),
("HTML files", "*.html"),
("JavaScript files", "*.js"),
("Batch files", "*.bat"),
("APK files", "*.apk")])
if file_path:
with open(file_path, 'w') as file:
file.write(self.text_editor.get("1.0", tk.END))
self.current_file = file_path # Update current file
def open_file(self):
file_path = filedialog.askopenfilename(filetypes=[("All files", "*.*")])
if file_path:
with open(file_path, 'r') as file:
self.text_editor.delete("1.0", tk.END)
self.text_editor.insert(tk.END, file.read())
self.current_file = file_path # Update current file
def new_project(self):
if self.text_editor.get("1.0", tk.END).strip(): # Check if there are unsaved changes
if messagebox.askyesno("Save Changes", "Do you want to save changes before starting a new project?"):
self.save_file()
self.text_editor.delete("1.0", tk.END) # Clear the text editor for a new project
self.current_file = None # Reset current file
def read_tutorial(self):
tutorial_text = "This is a simple coding tutorial. Learn how to code with examples."
self.engine.say(tutorial_text)
self.engine.runAndWait()
def zip_files(self):
file_paths = filedialog.askopenfilenames()
if file_paths:
zip_file = filedialog.asksaveasfilename(defaultextension=".zip")
with zipfile.ZipFile(zip_file, 'w') as zipf:
for file in file_paths:
zipf.write(file, os.path.basename(file))
messagebox.showinfo("Success", "Files zipped successfully!")
def launch_notepad(self):
subprocess.Popen(['notepad.exe'])
def show_about(self):
messagebox.showinfo("About", "SHAZIZZ Multi-Task Coding Tool\nVersion 1.0\nCreated for learning and coding.")
def on_exit(self):
if self.text_editor.get("1.0", tk.END).strip(): # Check if there are unsaved changes
if messagebox.askyesno("Save Changes", "Do you want to save changes before exiting?"):
self.save_file()
self.master.destroy() # Close the application
if __name__ == "__main__":
root = tk.Tk()
app = MultiTaskCoderApp(root)
root.geometry("800x600")
root.mainloop()
Navigate in the folder that you save the file in using the command prompt.
Use this command to run the file: python multi_task_coder.py
This program will require a few things to be installed PYTHON being the main one.
If you need help getting started contact me [email protected]
import tkinter as tk
from tkinter import filedialog, messagebox, simpledialog, colorchooser, Menu, Toplevel
import pyttsx3
import os
import zipfile
import subprocess
import webbrowser
class MultiTaskCoderApp:
def __init__(self, master):
self.master = master
master.title("SHAZIZZ Multi-Task Coding Tool")
# Set the default colors
self.bg_color = 'black'
self.text_color = 'lime'
self.button_color = 'red'
self.frame_color = 'black'
# Set the background color of the main window
master.configure(bg=self.bg_color)
# Text editor configuration
self.text_editor = tk.Text(master, wrap='word', undo=True, bg=self.bg_color, fg=self.text_color, insertbackground=self.text_color)
self.text_editor.pack(expand=1, fill='both')
self.toolbar = tk.Frame(master, bg=self.frame_color)
self.toolbar.pack(side='top', fill='x')
# Style for buttons
button_style = {
'bg': self.button_color,
'fg': 'white',
'activebackground': 'darkred',
'activeforeground': 'white',
'highlightthickness': 0
}
# Create a menu bar
self.menu_bar = Menu(master)
master.config(menu=self.menu_bar)
# Help Menu
self.help_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Help", menu=self.help_menu)
self.help_menu.add_command(label="About", command=self.show_about)
self.help_menu.add_command(label="Load Help File", command=self.load_help_file)
self.help_menu.add_command(label="Visit SHAZIZZ", command=self.visit_shazizz)
# Sample Code Menu
self.sample_code_menu = Menu(self.help_menu, tearoff=0)
self.menu_bar.add_cascade(label="Sample Code", menu=self.sample_code_menu)
self.sample_code_menu.add_command(label="Basic HTML Structure", command=self.insert_basic_html_structure)
self.sample_code_menu.add_command(label="Image Tag", command=self.insert_image_tag)
self.sample_code_menu.add_command(label="Link Tag", command=self.insert_link_tag)
self.sample_code_menu.add_command(label="Audio Tag", command=self.insert_audio_tag)
self.sample_code_menu.add_command(label="Video Tag", command=self.insert_video_tag)
# New entries for <center> and <p>
self.sample_code_menu.add_command(label="<center></center>", command=self.insert_center_tag)
self.sample_code_menu.add_command(label="<p></p>", command=self.insert_paragraph_tag)
self.sample_code_menu.add_command(label="Load Example.txt", command=self.load_example_file)
# Customize Menu
self.customize_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Customize the Look", menu=self.customize_menu)
self.customize_menu.add_command(label="Background Color", command=self.change_background_color)
self.customize_menu.add_command(label="Text Color", command=self.change_text_color)
self.customize_menu.add_command(label="Frame Color", command=self.change_frame_color)
self.customize_menu.add_command(label="Button Color", command=self.change_button_color)
# Command Prompt Menu
self.command_menu = Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label="Command Prompt", menu=self.command_menu)
self.command_menu.add_command(label="Open New Command Prompt", command=self.open_command_prompt)
# Add buttons to the toolbar
self.undo_button = tk.Button(self.toolbar, text="Undo", command=self.undo, **button_style)
self.undo_button.pack(side='left')
self.redo_button = tk.Button(self.toolbar, text="Redo", command=self.redo, **button_style)
self.redo_button.pack(side='left')
self.insert_image_button = tk.Button(self.toolbar, text="Insert Image", command=self.insert_image, **button_style)
self.insert_image_button.pack(side='left')
self.color_button = tk.Button(self.toolbar, text="Text Color", command=self.choose_text_color, **button_style)
self.color_button.pack(side='left')
self.size_button = tk.Button(self.toolbar, text="Text Size", command=self.choose_text_size, **button_style)
self.size_button.pack(side='left')
self.bg_color_button = tk.Button(self.toolbar, text="Background Color", command=self.choose_background_color, **button_style)
self.bg_color_button.pack(side='left')
self.title_button = tk.Button(self.toolbar, text="Add Title", command=self.add_title, **button_style)
self.title_button.pack(side='left')
self.voice_html_button = tk.Button(self.toolbar, text="Add Audio File", command=self.add_voice_to_html, **button_style)
self.voice_html_button.pack(side='left')
self.textbox_button = tk.Button(self.toolbar, text="Add Text Box", command=self.add_text_box, **button_style)
self.textbox_button.pack(side='left')
self.button_button = tk.Button(self.toolbar, text="Add Button", command=self.add_button, **button_style)
self.button_button.pack(side='left')
self.hyperlink_button = tk.Button(self.toolbar, text="Add Hyperlink", command=self.add_hyperlink, **button_style)
self.hyperlink_button.pack(side='left')
self.video_button = tk.Button(self.toolbar, text="Insert Video", command=self.insert_video, **button_style)
self.video_button.pack(side='left')
self.header_button = tk.Button(self.toolbar, text="Add Header", command=self.add_header, **button_style)
self.header_button.pack(side='left')
self.custom_script_button = tk.Button(self.toolbar, text="Custom Script", command=self.add_custom_script, **button_style)
self.custom_script_button.pack(side='left')
self.test_button = tk.Button(self.toolbar, text="Test in Browser", command=self.test_in_browser, **button_style)
self.test_button.pack(side='left')
self.save_button = tk.Button(master, text="Save as...", command=self.save_file, **button_style)
self.save_button.pack(side='left')
self.open_button = tk.Button(master, text="Open...", command=self.open_file, **button_style)
self.open_button.pack(side='left')
self.new_project_button = tk.Button(master, text="New Project", command=self.new_project, **button_style)
self.new_project_button.pack(side='left')
self.tutorial_button = tk.Button(master, text="Read Tutorial", command=self.read_tutorial, **button_style)
self.tutorial_button.pack(side='left')
self.zip_button = tk.Button(master, text="Zip Files", command=self.zip_files, **button_style)
self.zip_button.pack(side='left')
self.launch_app_button = tk.Button(master, text="Launch Notepad", command=self.launch_notepad, **button_style)
self.launch_app_button.pack(side='left')
self.engine = pyttsx3.init()
self.current_file = None # To keep track of the current file
# Right-click context menu
self.context_menu = Menu(master, tearoff=0)
self.context_menu.add_command(label="Select All", command=self.select_all)
self.context_menu.add_command(label="Cut", command=self.cut)
self.context_menu.add_command(label="Copy", command=self.copy)
self.context_menu.add_command(label="Paste", command=self.paste)
self.context_menu.add_command(label="Delete", command=self.delete)
# Bind the right-click event
self.text_editor.bind("<Button-3>", self.show_context_menu)
# Bind the close event to ask for saving changes
master.protocol("WM_DELETE_WINDOW", self.on_exit)
def select_all(self):
self.text_editor.tag_add("sel", "1.0", "end")
def load_help_file(self):
help_file_path = 'help.txt' # Ensure this file exists in the same directory
if os.path.exists(help_file_path):
with open(help_file_path, 'r') as file:
content = file.read()
# Create a new top-level window to display the help content
help_window = Toplevel(self.master)
help_window.title("Help")
help_text = tk.Text(help_window, wrap='word')
help_text.insert(tk.END, content)
help_text.pack(expand=1, fill='both')
help_text.config(state=tk.DISABLED) # Make it read-only
else:
messagebox.showerror("Error", "help.txt not found!")
def visit_shazizz(self):
webbrowser.open("https://www.shazizz.net")
def open_command_prompt(self):
subprocess.Popen("start cmd", shell=True)
def insert_center_tag(self):
self.text_editor.insert(tk.END, "<center></center>\n")
def insert_paragraph_tag(self):
self.text_editor.insert(tk.END, "<p></p>\n")
def load_example_file(self):
example_file_path = 'example.txt' # Ensure this file exists in the same directory
if os.path.exists(example_file_path):
with open(example_file_path, 'r') as file:
content = file.read()
self.text_editor.delete("1.0", tk.END) # Clear the editor before loading
self.text_editor.insert(tk.END, content)
else:
messagebox.showerror("Error", "example.txt not found!")
def show_context_menu(self, event):
self.context_menu.post(event.x_root, event.y_root)
def cut(self):
self.text_editor.event_generate("<<Cut>>")
def copy(self):
self.text_editor.event_generate("<<Copy>>")
def paste(self):
self.text_editor.event_generate("<<Paste>>")
def delete(self):
self.text_editor.delete("sel.first", "sel.last")
def change_background_color(self):
color = colorchooser.askcolor()[1]
if color:
self.bg_color = color
self.master.configure(bg=self.bg_color)
self.text_editor.config(bg=self.bg_color)
def change_text_color(self):
color = colorchooser.askcolor()[1]
if color:
self.text_color = color
self.text_editor.config(fg=self.text_color, insertbackground=self.text_color)
def change_frame_color(self):
color = colorchooser.askcolor()[1]
if color:
self.frame_color = color
self.toolbar.config(bg=self.frame_color)
def change_button_color(self):
color = colorchooser.askcolor()[1]
if color:
self.button_color = color
for widget in self.toolbar.winfo_children():
widget.config(bg=self.button_color)
def add_custom_script(self):
custom_script = simpledialog.askstring("Custom Script", "Enter your custom script:")
if custom_script:
self.text_editor.insert(tk.END, f"<script>\n{custom_script}\n</script>\n")
def insert_basic_html_structure(self):
html_code = """<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
"""
self.text_editor.insert(tk.END, html_code)
def insert_image_tag(self):
html_code = '<img src="image_url.jpg" alt="Image Description" />\n'
self.text_editor.insert(tk.END, html_code)
def insert_link_tag(self):
html_code = '<a href="http://example.com">This is a link</a>\n'
self.text_editor.insert(tk.END, html_code)
def insert_audio_tag(self):
html_code = """<audio controls>
<source src="audio_file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
"""
self.text_editor.insert(tk.END, html_code)
def insert_video_tag(self):
html_code = """<video width="320" height="240" controls>
<source src="video_file.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
"""
self.text_editor.insert(tk.END, html_code)
def insert_image(self):
# Open a file dialog to select an image
img_path = filedialog.askopenfilename(filetypes=[("Image files", ("*.jpg", "*.jpeg", "*.png", "*.gif"))])
if img_path:
# Insert the HTML img tag into the text editor
img_tag = f'<img src="{img_path}" alt="Image" />\n'
self.text_editor.insert(tk.END, img_tag)
def undo(self):
self.text_editor.edit_undo()
def redo(self):
self.text_editor.edit_redo()
def choose_text_color(self):
color = colorchooser.askcolor()[1]
if color:
html_code = f'<span style="color:{color};">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</span>\n') # Closing tag for span
def choose_text_size(self):
size = simpledialog.askinteger("Text Size", "Enter text size:", minvalue=1, maxvalue=100)
if size:
html_code = f'<span style="font-size:{size}px;">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</span>\n') # Closing tag for span
def choose_background_color(self):
color = colorchooser.askcolor()[1]
if color:
html_code = f'<div style="background-color:{color};">'
self.text_editor.insert(tk.END, html_code)
self.text_editor.insert(tk.END, '</div>\n') # Closing tag for div
def add_title(self):
title = simpledialog.askstring("Title", "Enter the title:")
if title:
self.text_editor.insert(tk.END, f"<title>{title}</title>\n")
def add_voice_to_html(self):
html_code = simpledialog.askstring("Add Audio File", "Enter Url to Audio File:")
if html_code:
self.text_editor.insert(tk.END, f"<audio controls>\n<source src='{html_code}' type='audio/mpeg'>\nYour browser does not support the audio element.\n</audio>\n")
def add_text_box(self):
self.text_editor.insert(tk.END, "<input type='text' placeholder='Your text here'>\n")
def add_button(self):
button_text = simpledialog.askstring("Button", "Enter button text:")
if button_text:
self.text_editor.insert(tk.END, f"<button>{button_text}</button>\n")
def add_hyperlink(self):
link_text = simpledialog.askstring("Hyperlink", "Enter link text:")
url = simpledialog.askstring("Hyperlink", "Enter URL:")
if link_text and url:
self.text_editor.insert(tk.END, f"<a href='{url}'>{link_text}</a>\n")
def insert_video(self):
video_url = simpledialog.askstring("Insert Video", "Enter video URL:")
if video_url:
self.text_editor.insert(tk.END, f"<video width='320' height='240' controls>\n<source src='{video_url}' type='video/mp4'>\nYour browser does not support the video tag.\n</video>\n")
def add_header(self):
header_text = simpledialog.askstring("Header", "Enter header text:")
if header_text:
self.text_editor.insert(tk.END, f"<h1>{header_text}</h1>\n")
def test_in_browser(self):
html_content = self.text_editor.get("1.0", tk.END)
with open("temp_test.html", "w") as file:
file.write(html_content)
webbrowser.open("temp_test.html")
def save_file(self):
file_path = filedialog.asksaveasfilename(defaultextension=".txt",
filetypes=[("Text files", "*.txt"),
("HTML files", "*.html"),
("JavaScript files", "*.js"),
("Batch files", "*.bat"),
("APK files", "*.apk")])
if file_path:
with open(file_path, 'w') as file:
file.write(self.text_editor.get("1.0", tk.END))
self.current_file = file_path # Update current file
def open_file(self):
file_path = filedialog.askopenfilename(filetypes=[("All files", "*.*")])
if file_path:
with open(file_path, 'r') as file:
self.text_editor.delete("1.0", tk.END)
self.text_editor.insert(tk.END, file.read())
self.current_file = file_path # Update current file
def new_project(self):
if self.text_editor.get("1.0", tk.END).strip(): # Check if there are unsaved changes
if messagebox.askyesno("Save Changes", "Do you want to save changes before starting a new project?"):
self.save_file()
self.text_editor.delete("1.0", tk.END) # Clear the text editor for a new project
self.current_file = None # Reset current file
def read_tutorial(self):
tutorial_text = "This is a simple coding tutorial. Learn how to code with examples."
self.engine.say(tutorial_text)
self.engine.runAndWait()
def zip_files(self):
file_paths = filedialog.askopenfilenames()
if file_paths:
zip_file = filedialog.asksaveasfilename(defaultextension=".zip")
with zipfile.ZipFile(zip_file, 'w') as zipf:
for file in file_paths:
zipf.write(file, os.path.basename(file))
messagebox.showinfo("Success", "Files zipped successfully!")
def launch_notepad(self):
subprocess.Popen(['notepad.exe'])
def show_about(self):
messagebox.showinfo("About", "SHAZIZZ Multi-Task Coding Tool\nVersion 1.0\nCreated for learning and coding.")
def on_exit(self):
if self.text_editor.get("1.0", tk.END).strip(): # Check if there are unsaved changes
if messagebox.askyesno("Save Changes", "Do you want to save changes before exiting?"):
self.save_file()
self.master.destroy() # Close the application
if __name__ == "__main__":
root = tk.Tk()
app = MultiTaskCoderApp(root)
root.geometry("800x600")
root.mainloop()
Copy and save these files in the same folder as your code and your exe file when you package it.
Notice: after you unzip the files copy the content to the same directory that your code and .exe files are in.

temp-files-for-multi-coder.zip | |
File Size: | 4 kb |
File Type: | zip |