Note by Yoshikawa

Love Technology and Art

tkinter ファイル選択ダイアログ

# --------------------------------------------------------
#                         フォルダパス取得
# --------------------------------------------------------
def absdirpath():
    iDir = os.path.abspath(os.path.dirname(__file__))
    root = tkinter.Tk()
    root.withdraw()
    dir = tkinter.filedialog.askdirectory(initialdir=iDir)
    return dir


# --------------------------------------------------------
#                         ファイルパス取得
# --------------------------------------------------------
def absfilepath():
    root = tkinter.Tk()
    root.withdraw()
    fTyp = [("","*")]
    iDir = os.path.abspath(os.path.dirname(__file__))
    file = tkinter.filedialog.askopenfilename(filetypes = fTyp,initialdir = iDir)
    return file