-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackupUI.py
More file actions
87 lines (71 loc) · 3.36 KB
/
backupUI.py
File metadata and controls
87 lines (71 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import tkinter as tk
from tkinter import filedialog, messagebox, ttk
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import mainUI as mainUIModule
from core.Wimkit import WimBackup, WIMOperation
class BackupUI:
def __init__(self, root):
self.root = root
self.root.title("DBAR Backup ToolBox")
self.root.geometry("600x300")
# Create interface components
self.create_widgets()
# Initialize backup object
self.backup_obj = None
def create_widgets(self):
# Source path selection
tk.Label(self.root, text="Source Path:").grid(row=0, column=0, padx=5, pady=5, sticky="e")
self.source_path = tk.Entry(self.root, width=50)
self.source_path.grid(row=0, column=1, padx=5, pady=5)
tk.Button(self.root, text="Browse", command=self.browse_source).grid(row=0, column=2, padx=5, pady=5)
# Progress bar
self.progress = ttk.Progressbar(self.root, length=400, mode='determinate')
self.progress.grid(row=4, column=0, columnspan=3, padx=5, pady=10)
# Status label
self.status_label = tk.Label(self.root, text="Ready")
self.status_label.grid(row=5, column=0, columnspan=3, pady=5)
# Backup button
self.backup_button = tk.Button(self.root, text="Start Backup", command=self.start_backup)
self.backup_button.grid(row=6, column=1, pady=10)
def browse_source(self):
"""Select source path"""
folder_selected = filedialog.askdirectory()
if folder_selected:
self.source_path.delete(0, tk.END)
self.source_path.insert(0, folder_selected)
def start_backup(self):
"""Start backup process"""
# Get input values
source = self.source_path.get()
# Disable backup button to prevent duplicate operations
self.backup_button.config(state=tk.DISABLED)
self.status_label.config(text="Initializing backup...")
self.status_label.config(text="Creating backup...")
# Build complete backup file path
# Create full backup
result = mainUIModule.MainUI.readSettingsInfoFromTXT("compressLevel")
if result == "Fast":
global success
success = WimBackup.creatFullBackup(source, compressLevel="1")
elif result == "Medium":
success = WimBackup.creatFullBackup(source, compressLevel="default")
else:
success = WimBackup.creatFullBackup(source, compressLevel="15")
if success:
self.status_label.config(text="Backup completed")
messagebox.showinfo("Success", "Backup has been successfully completed")
self.backup_button.config(state=tk.NORMAL)
else:
self.status_label.config(text="Backup failed")
messagebox.showerror("Error", "An error occurred during backup")
self.backup_button.config(state=tk.NORMAL)
def update_progress(self, value):
"""Update progress bar"""
self.progress['value'] = value
self.root.update_idletasks()
if __name__ == "__main__":
root = tk.Tk()
app = BackupUI(root)
root.mainloop()