This is the script
from tkinter import *
import os
window = Tk()
window.title("Download from Web")
window.geometry("300x120+200+100")
photo = PhotoImage(file = "icon/icon.png")
window.iconphoto(False, photo)
urltxt = Label(window, text = "Url").place(x = 10, y = 10)
url = Entry(window, width=30)
url.insert(0,"")
url.grid(row=1, column=0, padx=80, pady=10)
filetxt = Label(window, text = "Save File name").place(x = 10, y = 10)
filename = Entry(window, width=30)
filename.insert(0,".exe,.zip,.rar")
filename.grid(row=2, column=0, padx=80, pady=10)
def Message():
os.system(f"powershell -c "Invoke-WebRequest -Uri '{url.get()}' -OutFile '{filename.get()}'"")
btnSendMessage = Button(window, text="Search", width=20, command=Message)
btnSendMessage.grid(row=4, column=0, padx=10, pady=10)
window.mainloop()
I'm having a problem with this part of the text
def Message():
os.system(f"powershell -c "Invoke-WebRequest -Uri '{url.get()}' -OutFile '{filename.get()}'"")
I'm having a problem with these two parts in particular when I add the '
to the code I get an error
'{url.get()}' and '{filename.get()}'
Quotes can be escaped with backslashes as shown:
os.system(f"powershell -c \"Invoke-WebRequest -Uri \'{url.get()}\' -OutFile \'{filename.get()}\'\"")