Skip to content

Commit cf000b9

Browse files
committed
Renew Gui && Add Folders & files counting
1 parent ba7830b commit cf000b9

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

main.py

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import customtkinter as ctk
2-
from tkinter import filedialog, Label
2+
from tkinter import filedialog, Label, Frame
33
from CTkMessagebox import CTkMessagebox
44
import os
55
import sys
@@ -16,28 +16,39 @@ def __init__(self):
1616

1717
self.root = ctk.CTk()
1818
self.root.title("Recursive Symlink Creator")
19-
self.root.geometry("720x240") # Set window size
20-
self.root.resizable(False, False) # Make non-resizable
21-
self.source_label = Label(self.root, text="Source Folder:", bg='#242424', fg='#fff', font='Helvetica 12 bold')
22-
self.source_label.pack(fill="x",padx=5)
19+
self.root.geometry("720x255")
20+
self.root.resizable(False, False)
2321

24-
self.source_entry = ctk.CTkEntry(self.root)
22+
# Source sub-box
23+
source_frame = ctk.CTkFrame(self.root)
24+
source_frame.pack(fill="x", pady=5, padx=5)
25+
26+
self.source_label = Label(source_frame, text="Source Folder:", bg='#2b2b2b', fg='#fff', font='Helvetica 12 bold')
27+
self.source_label.pack(fill="x", padx=5)
28+
29+
self.source_entry = ctk.CTkEntry(source_frame)
2530
self.source_entry.pack(fill="x", padx=5)
26-
27-
self.browse_source_button = ctk.CTkButton(self.root, text="Browse", command=self.browse_source)
31+
32+
self.browse_source_button = ctk.CTkButton(source_frame, text="Browse", command=self.browse_source)
2833
self.browse_source_button.pack(pady=5)
2934

30-
self.dest_label = Label(self.root, text="Destination Folder:", bg='#242424', fg='#fff', font='Helvetica 12 bold')
31-
self.dest_label.pack(fill="x",padx=5)
35+
# Destination sub-box
36+
dest_frame = ctk.CTkFrame(self.root)
37+
dest_frame.pack(fill="x", pady=5, padx=5)
38+
39+
self.dest_label = Label(dest_frame, text="Destination Folder:", bg='#2b2b2b', fg='#fff', font='Helvetica 12 bold')
40+
self.dest_label.pack(fill="x", padx=5)
3241

33-
self.dest_entry = ctk.CTkEntry(self.root)
42+
self.dest_entry = ctk.CTkEntry(dest_frame)
3443
self.dest_entry.pack(fill="x", padx=5)
3544

36-
self.browse_dest_button = ctk.CTkButton(self.root, text="Browse", command=self.browse_dest)
45+
self.browse_dest_button = ctk.CTkButton(dest_frame, text="Browse", command=self.browse_dest)
3746
self.browse_dest_button.pack(pady=5)
3847

48+
# Create Symlinks button
3949
self.create_button = ctk.CTkButton(self.root, text="Create Symlinks", command=self.create_symlinks)
40-
self.create_button.pack(fill="x",pady=10, padx=5)
50+
self.create_button.pack(fill="x", pady=10, padx=5)
51+
4152
self.center_window(self.root)
4253

4354
def center_window(self, window):
@@ -58,11 +69,11 @@ def update_label_info(self, entry, label):
5869
path = entry.get()
5970
if os.path.exists(path):
6071
self.count_folders_and_files(path)
61-
label.config(text=f"{label.cget("text").split(':')[0]}: ({self.folder_count} folders, {self.file_count} files)")
72+
label.config(text=f"{label.cget('text').split(':')[0]}: ({self.folder_count} folders, {self.file_count} files)")
6273
self.folder_count = 0
6374
self.file_count = 0
6475
else:
65-
label.config(text=f"{label.cget("text").split(':')[0]}: 0")
76+
label.config(text=f"{label.cget('text').split(':')[0]}: 0")
6677

6778
def count_folders_and_files(self, path):
6879
"""Counts folders and files within the given path."""
@@ -135,11 +146,9 @@ def isUserAdmin():
135146

136147

137148
if __name__ == "__main__":
138-
gui = RecursiveSymlinkGUI()
139-
gui.run()
140-
# if len(sys.argv) < 2:
141-
# if not isUserAdmin():
142-
# run_as_admin()
143-
# sys.exit()
144-
# gui = RecursiveSymlinkGUI()
145-
# gui.run()
149+
if len(sys.argv) < 2:
150+
if not isUserAdmin():
151+
run_as_admin()
152+
sys.exit()
153+
gui = RecursiveSymlinkGUI()
154+
gui.run()

0 commit comments

Comments
 (0)