First, the necessary libraries are imported, including tkinter, ttk, os, windnd, and shutil. Then, a root window object named "root" is created, and the title, size, resizable, and icon of the window are set.
Next, a custom font style named "font_style" is defined, and several interface components are created, including "label_warning" (used to display warning messages), "label_volume" (used to display file quantity and execution results), "text" (used to display file paths), and "btn_execute" (used to execute the file crushing operation).
In the "handle_drag" function, the logic for handling dragged files is defined. It first clears the content of "text" and then iterates through the list of dragged files. It adds the file paths to the "files_A" list if the dragged item is a file. If the dragged item is a folder, it adds the folder path to the "folder_A" list and iterates through all the files in the folder, adding their paths to the "files_A" list. Finally, it adds the folder path to the "folder_B" list and displays the file and folder paths in "text".
In the "delete_file" function, the logic for deleting files is defined. If the file exists, it tries to open the file in write mode, writes a character to the file, and then deletes the file. If the deletion fails, it adds the file path to the "G" list.
In the "delete_folder" function, the logic for deleting folders is defined. If the folder does not exist, it directly adds the folder path to the "G" list. If the folder exists, it tries to recursively delete the folder. If the deletion fails, it adds the folder path to the "G" list.
In the "execute" function, the logic for executing the file crushing operation is defined. It first disables the "btn_execute" button and clears the content of "text". Then, it iterates through the "files_A" list and calls the "delete_file" function to delete the files. It then iterates through the "folder_B" list and calls the "delete_folder" function to delete the folders. Finally, it displays the information of the exception files in the "G" list in "text" and updates the text of "label_volume". Finally, it enables the "btn_execute" button again.
Lastly, the function "handle_drag" is set as the handler for dragged files, and the main event loop is started with "root.mainloop()".
Drag the files to be crushed into the window and click the "一键粉碎" button to start the crushing process.