-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
89 lines (66 loc) · 3.7 KB
/
Copy pathapp.py
File metadata and controls
89 lines (66 loc) · 3.7 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
88
89
import tkinter as tk
from tkinter import Label, filedialog, Text
import os
root = tk.Tk()
# Create appending method here, loop over this later on as well
# This empty array is what all of our added .exe files will get pushed too
apps = []
# Error handling, this gets rid of empty places in our files, accounting for if a user where to select a blank or invalid file type
if os.path.isfile('save.txt'):
with open('save.txt', 'r') as f:
tempApps = f.read()
# print(tempApps)
# This organizes the users input files by seperating them by commas
tempApps = tempApps.split(',')
# Strips out any existing white space or gaps between our chosen apps
apps = [x for x in tempApps if x.strip()]
def addApp():
# Create a function that stops appended files from repeating on top of each other upon every new appendage
for widget in frame.winfo_children():
widget.destroy()
# Drill down into root file (C drive) and filter so that only files with the .exe designation are displayed as available to interact with to users
filename = filedialog.askopenfilename(initialdir="/", title="Select File",
filetypes=(("executables","*.exe"), ("all files", "*.*")))
apps.append(filename)
print(filename)
# Indentation matters, be careful where you place variables
# Add files and their paths to our main working area
for app in apps:
label = tk.Label(frame, text=app, bg="royalblue")
label.pack()
# Create a funtion that loops over our apps array and allows the operating system to run the files
def runApps():
for app in apps:
os.startfile(app)
# Outer frame that holds our work space
canvas = tk.Canvas(root, height=700, width=700, bg="deepskyblue")
canvas.pack()
# Inner frame for our files to be stored on
frame = tk.Frame(root, bg="white")
frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1)
# Now create a clickable button that is attached to the root, not the workspace. AKA it will sit parallel with the borders of the application, add in our command function that is defined above.
openFile = tk.Button(root, text="Open File", padx=10,
pady=5, fg="white", bg="red", command=addApp)
openFile.pack()
# Create 2nd clickable root button that runs our selected applications, add in our command function that is defined above
runApps = tk.Button(root, text="Run Apps", padx=10,
pady=5, fg="white", bg="red", command=runApps)
runApps.pack()
# Setup previously entered apps persisting upon reload
for app in apps:
label = tk.Label(frame, text=app)
label.pack()
root.mainloop()
# Whenever app is closed this creates a text file that saves all files the user ran in that particular instance
# Technically speaking, this loops over apps again and gives users the ability to save their files (w=write)
with open('save.txt', 'w') as f:
for app in apps:
f.write(app + ',')
# Future Dev
# Would like to add a "routines" feature that a user could open up depening upon their desired outcome
# For example a user could have a "Work From Home" routine containing all neccessary programs for that situation
# A user could also have a "Gaming" routine that opens their desired client for gaming and possibly the steam store so they could add to their arsenal
# Could also add a delete button within the root that can just delete individual files from your lineup
# lets say if a user accidently added something they dont care to have there
# Would love to create an automated delete feature that would scrap whole files
# In the event an entire routine got outdated, you could kill it