Skip to content

Commit

Permalink
added multi-file selection
Browse files Browse the repository at this point in the history
  • Loading branch information
captainAyan committed Oct 7, 2024
1 parent 7be7555 commit 52618ac
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,34 @@ def modify_image_with_random_data(file_path):


def submit():
"""Handle the submit button click."""
file_path = file_entry.get()
if os.path.isfile(file_path):
modify_image_with_random_data(file_path)
messagebox.showinfo("Success", f"Corrupted {file_path} with random data.")
total_files = listbox.size()
if total_files != 0:
for index in range(total_files):
file_path = listbox.get(index) # Get the file path from the Listbox

if os.path.isfile(file_path):
modify_image_with_random_data(file_path) # Call your function to modify the image
else:
messagebox.showerror("Error", f"File not found: {file_path}")
messagebox.showinfo("Success", "Corrupted files with random data.")
else:
messagebox.showerror("Error", "File not found!")
messagebox.showerror("Error", "No files selected!")


def browse_file():
"""Open file dialog to select a file."""
filename = filedialog.askopenfilename(filetypes=[("PNG Files", "*.png"), ("All Files", "*.*")])
file_entry.delete(0, tk.END) # Clear the entry
file_entry.insert(0, filename) # Insert the selected file path
filenames = filedialog.askopenfilenames(filetypes=[("All Files", "*.*")])

listbox.delete(0, tk.END)

if filenames:
for filename in filenames:
listbox.insert(tk.END, filename) # Insert each selected file into the Listbox

message_label.config(text=f"{listbox.size()} {'file' if listbox.size()==1 else 'files'} selected")
else:
message_label.config(text="Select a file to corrupt:")



# mongo smoothie theme
Expand All @@ -46,7 +60,7 @@ def browse_file():
# Create the main window
root = tk.Tk()
root.title("Corruptinator")
root.geometry("400x320") # Set a fixed size for the window
root.geometry("400x360") # Set a fixed size for the window
root.configure(bg=bg_color) # Set background color
root.resizable(False, False)

Expand All @@ -58,17 +72,17 @@ def browse_file():
frame = tk.Frame(root, bg=bg_color)
frame.pack(padx=20, pady=0)

tk.Label(frame, text="Select a file to corrupt:", bg=bg_color, font=("Arial", 12), fg=text_color).pack(pady=10)

file_entry = tk.Entry(frame, width=400, font=("Arial", 12), bd=2, relief="groove")
file_entry.pack(pady=10)
message_label = tk.Label(frame, text="Select a file to corrupt:", bg=bg_color, font=("Arial Black", 10), fg=text_color)
message_label.pack(pady=10)

listbox = tk.Listbox(frame, width=400, height=5) # You can adjust the width and height as needed
listbox.pack(pady=2)

browse_button = tk.Button(frame, text="Browse", command=browse_file, bg=browse_btn_color, fg="white", font=("Arial Black", 12), bd=0, width=400)
browse_button.pack(pady=5)
browse_button.pack(pady=2)

submit_button = tk.Button(frame, text="Corrupt", command=submit, bg=submit_btn_color, fg="white", font=("Arial Black", 12), bd=0, width=400)
submit_button.pack(pady=5)
submit_button.pack(pady=2)

github_link = "GitHub @captainayan"
github_label = tk.Label(root, text=github_link, bg=bg_color, font=("Arial", 10), fg="#007BFF")
Expand Down

0 comments on commit 52618ac

Please sign in to comment.