-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_load.py
66 lines (47 loc) · 1.5 KB
/
app_load.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
from tkinter import *
from tkinter.ttk import *
import tkinter.filedialog
import os, sys, subprocess
root = Tk()
root.title("My App Runner")
root.geometry("350x400")
#app list
apps = []
#to make sure the app doesn't enter an empty value to the list
if os.path.isfile('save.txt'):
with open('save.txt', "r") as f:
tempApps = f.read()
tempApps = tempApps.split(',')
apps = [x for x in tempApps if x.strip()] #removes the empty value
#to add the app
def addApp():
for widget in myCanvas.winfo_children():
widget.destroy()
filename= tkinter.filedialog.askopenfilename( initialdir=".", title= "Select a File",
filetypes = (("executables", "*.app"), ("all files,", "*.*")))
apps.append(filename)
print(filename)
for app in apps:
label= Label(myCanvas, text= app, background= "gray")
label.pack()
#to run the app
def runApps():
for app in apps:
subprocess.call(["open", app]) #for windows,use os.startfile(app)
#background
myCanvas= Canvas(root, width=350, height=350, background= "#2242B4")
myCanvas.pack()
#buttons
myButton = Button(root, text = 'Open Files', command= addApp)
runButton = Button(root, text= "Run Apps", command= runApps)
myButton.pack(side=BOTTOM)
runButton.pack(side=BOTTOM)
#to save on Canvas
for app in apps:
label= Label(myCanvas, text=app)
label.pack()
root.mainloop()
#to save the apps
with open("save.txt", 'w') as f:
for app in apps:
f.write(app + ',')