Tutorial for developers, IT pros, and power users
Direct download & release: FileSync PRO v4.0.0
SEO tags: Python backup tool, file synchronization Python, Tkinter file sync, Python multi-thread copy, real-time folder monitoring, encrypted backups Python, professional desktop tools
ποΈ Architecture Overview
FileSync PRO is built with Python using:
Tkinter + ttkbootstrap β Modern GUI
Watchdog β Real-time folder monitoring
ThreadPoolExecutor β Multi-threaded copy engine
Cryptography (Fernet) β Optional encrypted backups
Hash verification β Ensures data integrity
Architecture Diagram
βββββββββββββββββ βββββββββββββββββ
β Source Folderβββββββ>β Sync Engine β
β β β β
β Real-time β β Multi-thread β
β Monitoring β β File Copy β
ββββββββ¬βββββββββ βββββββββ¬ββββββββ
β β
β β
β βββββββΌββββββ
β β Target β
β β Folder β
β βββββββββββββ
β
β
β βββββββββββββ
β β Backup β
ββββββββββββββββββ>β (ZIP & β
β Encryptionβ
βββββββββββββ
1οΈβ£ Setting Up the Project
Install required packages:
pip install ttkbootstrap watchdog cryptography
ttkbootstrap β Modern Tkinter styling
watchdog β File system events for real-time sync
cryptography β Optional encryption of backups
Create your main Python file, e.g., filesync_pro.py.
2οΈβ£ Initializing the App
Start by importing necessary modules and setting up the basic app window:
import tkinter as tk
from queue import Queue
import ttkbootstrap as tb
from ttkbootstrap.constants import *
# App Configuration
APP_NAME = "FileSync PRO"
APP_VERSION = "4.0.0"
# UI queue for thread-safe logging
ui_queue = Queue()
# Initialize main window
app = tk.Tk()
app.title(f"{APP_NAME} {APP_VERSION}")
app.geometry("1200x640")
tb.Style("darkly")
Explanation:
We use a Queue for thread-safe communication between background threads (sync engine) and the UI.
3οΈβ£ Folder Selection & Settings
Add folder selection for source and target directories:
source_folder = tb.StringVar()
target_folder = tb.StringVar()
def browse_source():
folder = tk.filedialog.askdirectory()
if folder:
source_folder.set(folder)
def browse_target():
folder = tk.filedialog.askdirectory()
if folder:
target_folder.set(folder)
Explanation:
Tkinterβs filedialog.askdirectory() allows users to pick folders for synchronization.
4οΈβ£ Logging & Progress Updates
We use a Text widget and Progressbar for live updates:
log_text = tk.Text(app, height=10, state="disabled")
log_text.pack(fill="both", expand=True)
progress = tb.Progressbar(app, bootstyle="success-striped")
progress.pack(fill="x", padx=10, pady=5)
def log(msg):
ui_queue.put(("log", msg))
def update_progress(value):
ui_queue.put(("progress", value))
Explanation:
Logs are queued to avoid thread conflicts, and progress updates keep the user informed.
5οΈβ£ File Hashing & Filtering
import hashlib, os
filter_ext = tb.StringVar(value="")
def hash_file(path):
md5 = hashlib.md5()
with open(path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
md5.update(chunk)
return md5.hexdigest()
def allowed_file(file):
ext = filter_ext.get().strip()
if not ext:
return True
allowed = [e.strip().lower() for e in ext.split(",")]
return os.path.splitext(file)[1].lower() in allowed
Explanation:
hash_file ensures file integrity during sync
allowed_file enables extension-based filtering (.txt,.pdf,.py)
6οΈβ£ Multi-Threaded File Sync
import shutil
from concurrent.futures import ThreadPoolExecutor
files_synced = 0
bytes_copied = 0
def sync_file(src, dst):
global files_synced, bytes_copied
os.makedirs(os.path.dirname(dst), exist_ok=True)
if not os.path.exists(dst) or os.path.getmtime(src) > os.path.getmtime(dst):
shutil.copy2(src, dst)
files_synced += 1
bytes_copied += os.path.getsize(src)
log(f"β Synced: {os.path.basename(src)}")
def full_sync():
src = source_folder.get()
dst = target_folder.get()
file_list = []
for root, dirs, files in os.walk(src):
for f in files:
if allowed_file(f):
file_list.append(os.path.join(root, f))
executor = ThreadPoolExecutor(max_workers=6)
for src_file in file_list:
rel = os.path.relpath(src_file, src)
dst_file = os.path.join(dst, rel)
executor.submit(sync_file, src_file, dst_file)
executor.shutdown(wait=True)
Explanation:
Multi-threaded copy improves performance
Only copies changed files using mtime
7οΈβ£ Optional ZIP Backup & Encryption
import zipfile
from cryptography.fernet import Fernet
encrypt_backup = tb.BooleanVar(value=False)
zip_backup = tb.BooleanVar(value=False)
def create_zip_backup(folder):
zip_path = f"{folder}_backup.zip"
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
for root, dirs, files in os.walk(folder):
for f in files:
file_path = os.path.join(root, f)
z.write(file_path, os.path.relpath(file_path, folder))
log(f"π¦ Backup created: {zip_path}")
def encrypt_file(path):
key = Fernet.generate_key()
fernet = Fernet(key)
with open(path, "rb") as f:
encrypted = fernet.encrypt(f.read())
with open(path + ".enc", "wb") as f:
f.write(encrypted)
Explanation:
Optional ZIP archives and encryption secure your backups.
8οΈβ£ Real-Time Monitoring
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class SyncHandler(FileSystemEventHandler):
def on_modified(self, event):
if not event.is_directory and allowed_file(event.src_path):
dst = os.path.join(target_folder.get(), os.path.relpath(event.src_path, source_folder.get()))
sync_file(event.src_path, dst)
observer = Observer()
observer.schedule(SyncHandler(), source_folder.get(), recursive=True)
observer.start()
Explanation:
Uses watchdog to detect file changes
Syncs immediately to the target folder
9οΈβ£ Running the App
app.after(100, process_ui_queue)
app.mainloop()
Explanation:
process_ui_queue handles logs, progress, and stats updates
mainloop() starts the Tkinter GUI
β Final Notes
FileSync PRO v4.0.0 Features:
β‘ Real-time folder monitoring
π Multi-threaded high-performance copy
π§ Hash verification
π¦ ZIP backup with optional encryption
π Mirror mode & extension filtering
π Sync analytics dashboard
Download: GitHub Release v4.0.0

Top comments (0)