Home > Net >  How to add a download path to gui application in python tkinter
How to add a download path to gui application in python tkinter

Time:12-28

How would I add this download path to my GUI application in tkinter that I am making using python?

downloads_path = str(Path.home() / "Downloads")

To this


    with open(f"{name}.mp4", "wb") as out:
        out.write(video_bytes)

CodePudding user response:

Since you have already used pathlib.Path class, you can keep downloads_path as of type pathlib.Path instead of string:

downloads_path = Path.home() / "Downloads"

Then you can use it inside 2nd code block as below:

with open(downloads_path/f"{name}.mp4", "wb") as out:
    out.write(video_bytes)

If you still want to keep downloads_path as string, then you can use os.path.join(...) as below:

import os

...

with open(os.path.join(downloads_path, f"{name}.mp4"), "wb") as out:
    out.write(video_bytes)
  • Related