I have a problem, and I have no idea why it doesn't work!! :o I want to remove text files via tkinter, so when the 'user' writes the text file's name and clicks on the button, it will be removed.
from tkinter import *
import tkinter.messagebox
import os, time
root = Tk()
root.geometry('450x320')
root.title('Remove a Text File')
def remove():
if et in os.listdir():
os.remove(et)
tkinter.messagebox.showinfo('Removed!', 'Successfully Removed!')
else:
tkinter.messagebox.showerror('Error!', 'File not found!')
label1 = Label(root, text = 'What to remove ?')
label1.place(x = 70, y = 140)
entry1 = Entry(root)
entry1.place(x = 180, y = 140)
#To fix extension bug
et = entry1.get()
if '.txt' not in et:
et += '.txt'
button1 = Button(root, text = 'Remove', command = remove)
button1.place(x = 210, y = 200)
root.mainloop()