0% found this document useful (0 votes)
3 views

Python_Application_Code

This document contains a Python application source code for a file processing tool using Tkinter for the GUI. The application allows users to select a folder, processes a maximum of 15 files with a simulated delay, and moves the processed folder to a new location with a timestamp. It includes a progress bar to indicate the processing status and updates the UI upon completion.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python_Application_Code

This document contains a Python application source code for a file processing tool using Tkinter for the GUI. The application allows users to select a folder, processes a maximum of 15 files with a simulated delay, and moves the processed folder to a new location with a timestamp. It includes a progress bar to indicate the processing status and updates the UI upon completion.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Application Source Code

import os
import shutil
import time
import tkinter as tk
from tkinter import filedialog, ttk

class FileProcessorApp:
def __init__(self, root):
self.root = root
self.root.title("File Processor")

self.label = tk.Label(root, text="Select Folder to Process")


self.label.pack()

self.select_button = tk.Button(root, text="Browse", command=self.select_folder)


self.select_button.pack()

self.start_button = tk.Button(root, text="Start Processing", command=self.process_files,


state=tk.DISABLED)
self.start_button.pack()

self.progress = ttk.Progressbar(root, length=200, mode="determinate")


self.progress.pack()

self.folder_path = ""

def select_folder(self):
self.folder_path = filedialog.askdirectory()
if self.folder_path:
self.start_button.config(state=tk.NORMAL)

def process_files(self):
files = os.listdir(self.folder_path)
total_files = min(15, len(files))
self.progress["maximum"] = total_files

for i, file in enumerate(files[:total_files]):


time.sleep(1) # Simulating processing time
self.progress["value"] = i + 1
self.root.update_idletasks()

timestamp = time.strftime("%Y%m%d_%H%M%S")
new_folder_name = f"{self.folder_path}_processed_{timestamp}"
shutil.move(self.folder_path, new_folder_name)

self.label.config(text="Processing Complete!")

if __name__ == "__main__":
root = tk.Tk()
app = FileProcessorApp(root)
root.mainloop()

You might also like