Skip to content

Commit 581738b

Browse files
jnmontejanot2013anurag
authored andcommitted
Temp file deletion in python with Tkinter (hacktoberfest17#1182)
Create a GUI that will remove temp files and clean disk.
1 parent 926be40 commit 581738b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

TempFileCleanup.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from Tkinter import *
2+
import subprocess
3+
import os
4+
#tkinter import - os are libraries that are called into play to all us to use subprocess, check_call and frames
5+
master = Tk()
6+
master.title("Jarvis Support Tool")
7+
master.geometry("300x100")
8+
#Popen allows for the use of Win Dos commands to run
9+
#cmd calls cmd.exe
10+
#/K tells cmd.exe to run the next commands
11+
#del bla bla bla deletes all* temp files that are not in use
12+
def cleanTemp():subprocess.Popen(['cmd', '/K', 'del /q/f/s %TEMP%\*'])
13+
def cleanDisk():subprocess.check_call(['cleanmgr.exe', '/d', '/sagerun:1'])
14+
#Check_call looks for the program and runs it with what ever options after commas
15+
#Below are variables that buttons are being stored into and the .pack is "Embedding" the code per se
16+
b = Button(master, text="Clean Temp Files", command=cleanTemp)
17+
b.pack()
18+
c = Button(master, text="Clean Disk", command=cleanDisk)
19+
c.pack()
20+
mainloop()
21+
#mainloop here makes this whole process stay alive even after an option is selected. Otherwise it would close upon button selection
22+
#Developed by JM

0 commit comments

Comments
 (0)