Tkinter - open "Start" with recent files as in Windows file explorer

27 views Asked by At

Opening the windows "recent" folder with tkinter like so

from pathlib import Path
from tkinter import filedialog, Tk
from pathlib import Path
import os

appdata = Path(os.getenv("APPDATA"))  # type: ignore
recent = appdata / "Microsoft" / "Windows" / "Recent"
root = Tk()
root.withdraw()
res = Path(
    filedialog.askopenfilename(
        initialdir=recent,
        defaultextension="*.txt",
        filetypes=(("txt file", "*.txt"), ("all", "*.*")),
    )
)

will not result in a filtered list of recent files. Since this windows folder contains links only (.lnk).

What would be the best way to obtain a file open dialog with a list of recent files filtered for a certain file type on a windows machine?

0

There are 0 answers