-
Notifications
You must be signed in to change notification settings - Fork 0
/
demos.py
108 lines (85 loc) · 3.13 KB
/
demos.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import tkinter as tk
from tkinter import ttk
from tkinter.messagebox import showinfo
from delete_files_in_subdirs import delete_files_in_subdirs
from prefix_rename import prefix_rename
TEAL = "#2596be"
PURPLE = "#6c25be"
GOLD = "#bea925"
IRON = "#D8D9DA"
BOULDER = "#7D7D7D"
class App(tk.Tk):
def __init__(self):
super().__init__()
# setting the title of the main window
self.title("Demos")
# set the size and position of the window
self.geometry("300x600+650+250")
# disabling the resizable option
self.resizable(0, 0)
# setting the background color to #D8E9E6
self.configure(bg=PURPLE)
self.header_frame = tk.Frame(self, bg=PURPLE,
borderwidth=3, relief="solid")
self.buttons_frame = tk.Frame(
self, bg=PURPLE, borderwidth=3, relief="solid")
# using the pack() method to place the frames in the window
self.header_frame.pack(fill="both")
self.buttons_frame.pack(expand=True, fill="both")
# creating a label using the Label() widget
self.header_label = tk.Label(
self.header_frame,
text="Script Demos",
font=("arial bold", "36"),
fg=IRON,
bg=TEAL,
borderwidth=6,
relief="solid"
)
# using the pack() method to place the label in the window
self.header_label.pack(expand=True, fill="both", pady=8,
padx=8, ipady=10)
# Button that calls the delete_files_in_subdirs() function
self.del_in_subdirs_button = tk.Button(
self.buttons_frame,
text="Delete All Files in Subdirs",
font=("arial bold", "18"),
bg=IRON,
fg=TEAL,
activeforeground=PURPLE,
relief="groove",
command=delete_files_in_subdirs
)
self.del_in_subdirs_button.pack(pady=10)
# Button that calls the delete_files_in_subdirs() function
self.prefix_button = tk.Button(
self.buttons_frame,
text="Prefix all Files in Directory",
font=("arial bold", "18"),
bg=IRON,
fg=TEAL,
activeforeground=PURPLE,
relief="groove",
command=self.open_prefix_window
)
self.prefix_button.pack(pady=10)
# def button_clicked(self):
# showinfo(title='Information', message='Hello, Tkinter!')
def open_prefix_window(self):
pre_win = tk.Toplevel()
string_var = tk.StringVar()
pre_win.title("Set Prefix String")
pre_label = tk.Label(pre_win, text="Enter a prefix string:")
pre_label.grid(column=0, row=0)
pre_entry = tk.Entry(pre_win, textvariable=string_var)
pre_entry.grid(column=0, row=1)
pre_button = tk.Button(
pre_win,
text="Set Prefix String and Pick Dir",
command=lambda: prefix_rename(string_var.get(), pre_win)
)
pre_button.grid(column=0, row=2)
pre_win.mainloop()
if __name__ == "__main__":
app = App()
app.mainloop()