samedi 4 septembre 2021

My Tkinter filedialog is not working with my input and my if statement

When I run my program the if statement and the print work fine, but the filedialog is the only thing that does not work? I found out that my input is my problem, if I remove the input and change download to True instead of a input, the filedialog works fine. This might my ide or python problem, but I think it is just a code problem, and is there any alternative to my code, that might work?

from tkinter import Tk, filedialog
tk = Tk()
tk.withdraw()
download = input("Would you like to download the file?").lower()
if download == "yes":
    print("Choose where you would like to download it:")
    directory = filedialog.askdirectory()
    print(directory)

Aucun commentaire:

Enregistrer un commentaire