QuantumEcho Weaver Python GUI
👤 Sharing: AI
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import os
import threading
import time
import random
class QuantumEchoWeaverApp:
def __init__(self, master):
self.master = master
master.title("QuantumEcho Weaver - Advanced File Management & Automation")
master.geometry("800x600")
self.file_paths = []
self.processed_count = 0
self.is_processing = False
# Style Configuration
self.style = ttk.Style()
self.style.configure('TButton', padding=5, relief="raised")
self.style.configure('TLabel', padding=5)
self.style.configure('TEntry', padding=5)
self.style.configure('TProgressbar', thickness=20)
# UI Elements
self.create_widgets()
def create_widgets(self):
# File Selection Frame
file_frame = ttk.Frame(self.master, padding=10)
file_frame.pack(fill=tk.X)
self.file_button = ttk.Button(file_frame, text="Select Files", command=self.select_files)
self.file_button.pack(side=tk.LEFT)
self.file_list = tk.Listbox(file_frame, height=5, width=50)
self.file_list.pack(side=tk.LEFT, fill=tk.X, expand=True)
# Processing Options Frame
options_frame = ttk.Frame(self.master, padding=10)
options_frame.pack(fill=tk.X)
ttk.Label(options_frame, text="Action:").pack(side=tk.LEFT)
self.action_var = tk.StringVar(value="encrypt") # Default value
self.action_dropdown = ttk.Combobox(options_frame, textvariable=self.action_var, values=["encrypt", "decrypt", "compress", "extract", "rename"], state="readonly")
self.action_dropdown.pack(side=tk.LEFT)
ttk.Label(options_frame, text="Key (optional):").pack(side=tk.LEFT)
self.key_entry = ttk.Entry(options_frame, width=20)
self.key_entry.pack(side=tk.LEFT)
# Destination Frame
destination_frame = ttk.Frame(self.master, padding=10)
destination_frame.pack(fill=tk.X)
ttk.Label(destination_frame, text="Destination Folder:").pack(side=tk.LEFT)
self.destination_var = tk.StringVar()
self.destination_entry = ttk.Entry(destination_frame, textvariable=self.destination_var, width=40)
self.destination_entry.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.destination_button = ttk.Button(destination_frame, text="Browse", command=self.select_destination)
self.destination_button.pack(side=tk.LEFT)
# Progress Frame
progress_frame = ttk.Frame(self.master, padding=10)
progress_frame.pack(fill=tk.X)
self.progress_bar = ttk.Progressbar(progress_frame, orient=tk.HORIZONTAL, length=300, mode='determinate')
self.progress_bar.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.status_label = ttk.Label(progress_frame, text="Ready")
self.status_label.pack(side=tk.LEFT)
# Control Frame
control_frame = ttk.Frame(self.master, padding=10)
control_frame.pack(fill=tk.X)
self.start_button = ttk.Button(control_frame, text="Start Processing", command=self.start_processing)
self.start_button.pack(side=tk.LEFT)
self.stop_button = ttk.Button(control_frame, text="Stop Processing", command=self.stop_processing)
self.stop_button.pack(side=tk.LEFT)
self.stop_button['state'] = 'disabled'
self.details_button = ttk.Button(control_frame, text="Details", command=self.show_details)
self.details_button.pack(side=tk.RIGHT)
def select_files(self):
filepaths = filedialog.askopenfilenames()
if filepaths:
self.file_paths = list(filepaths)
self.file_list.delete(0, tk.END)
for path in self.file_paths:
self.file_list.insert(tk.END, os.path.basename(path))
self.status_label.config(text=f"{len(self.file_paths)} files selected.")
def select_destination(self):
destination = filedialog.askdirectory()
if destination:
self.destination_var.set(destination)
self.status_label.config(text=f"Destination set to: {destination}")
def start_processing(self):
if not self.file_paths:
messagebox.showerror("Error", "Please select files to process.")
return
if not self.destination_var.get():
messagebox.showerror("Error", "Please select a destination folder.")
return
self.is_processing = True
self.processed_count = 0
self.progress_bar['value'] = 0
self.progress_bar['maximum'] = len(self.file_paths)
self.start_button['state'] = 'disabled'
self.stop_button['state'] = 'normal'
self.status_label.config(text="Processing...")
threading.Thread(target=self.process_files_thread, daemon=True).start()
def stop_processing(self):
self.is_processing = False
self.stop_button['state'] = 'disabled'
self.start_button['state'] = 'normal'
self.status_label.config(text="Processing stopped.")
def process_files_thread(self):
action = self.action_var.get()
key = self.key_entry.get()
destination = self.destination_var.get()
for file_path in self.file_paths:
if not self.is_processing:
break # Stop if processing is cancelled
try:
self.process_file(file_path, action, key, destination)
except Exception as e:
messagebox.showerror("Error", f"Error processing {os.path.basename(file_path)}: {e}")
self.processed_count += 1
progress = (self.processed_count / len(self.file_paths)) * 100
self.progress_bar['value'] = progress
self.master.after(10, self.update_status, f"Processed {os.path.basename(file_path)} ({self.processed_count}/{len(self.file_paths)})") # Use after to update GUI from thread
time.sleep(0.1) # Simulate processing time
self.master.after(10, self.processing_complete) # Use after to update GUI from thread
def process_file(self, file_path, action, key, destination):
# Simulate file processing (replace with actual logic)
file_name = os.path.basename(file_path)
destination_path = os.path.join(destination, file_name + ".processed")
if action == "encrypt":
with open(file_path, "rb") as infile, open(destination_path, "wb") as outfile:
data = infile.read()
# Simple XOR encryption
encrypted_data = bytes([b ^ ord(key[i % len(key)]) for i, b in enumerate(data)]) if key else data #apply key if exists
outfile.write(encrypted_data)
elif action == "decrypt":
with open(file_path, "rb") as infile, open(destination_path, "wb") as outfile:
data = infile.read()
# Simple XOR decryption
decrypted_data = bytes([b ^ ord(key[i % len(key)]) for i, b in enumerate(data)]) if key else data #apply key if exists
outfile.write(decrypted_data)
elif action == "compress":
# Dummy compression
with open(file_path, "rb") as infile, open(destination_path, "wb") as outfile:
data = infile.read()
outfile.write(data[:len(data)//2]) # Just write half the data
elif action == "extract":
# Dummy extraction
with open(file_path, "rb") as infile, open(destination_path, "wb") as outfile:
data = infile.read()
outfile.write(data*2) #duplicate the data
elif action == "rename":
os.rename(file_path, os.path.join(destination, "renamed_" + file_name)) #rename the file
else:
raise ValueError(f"Invalid action: {action}")
time.sleep(random.uniform(0.1, 0.5)) # Simulate variable processing time
def update_status(self, message):
self.status_label.config(text=message)
def processing_complete(self):
self.is_processing = False
self.start_button['state'] = 'normal'
self.stop_button['state'] = 'disabled'
self.status_label.config(text="Processing complete.")
messagebox.showinfo("Complete", "File processing complete!")
def show_details(self):
messagebox.showinfo("Details",
"QuantumEcho Weaver is a versatile file management tool designed to streamline various file operations. It allows users to select multiple files and perform actions such as encryption, decryption, compression, extraction and renaming. The application provides a user-friendly interface for selecting files, choosing a destination directory, and monitoring progress. Features include:
- Batch File Processing: Process multiple files simultaneously.
- Various Actions: Supports encryption, decryption, compression, and more.
- Progress Tracking: Real-time progress updates with a progress bar.
- Customizable Options: Optional key for encryption/decryption.
- Error Handling: Robust error handling to prevent interruptions.
This tool is ideal for users who need to efficiently manage and manipulate large numbers of files with ease.")
root = tk.Tk()
app = QuantumEchoWeaverApp(root)
root.mainloop()
👁️ Viewed: 9
Comments