簡體   English   中英

將文件路徑打印到 label

[英]Printing a file path to a label

I am writing a windows application using python where I am trying to get the path to a specific folder in the C:\Users\\AppData\Roaming folder and print it to a label. 我已經嘗試了文件對話框,它只讓我 select 一個文件而不是一個文件夾打印到 label。

def getcache():
    root.filename = filedialog.askopenfilename(initialdir="%appdata%", title="Select Cache Folder")

這是我通常用來獲取特定文件的方法。 但在這種情況下,我正在尋找一個文件夾以打印到 label。

如果您使用的是Tkinter ,您可以嘗試使用 askdirectory:

from tkinter import filedialog
cache_folder = filedialog.askdirectory(initialdir="%appdata%", title="Select Cache Folder")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM