Skip to content

Instantly share code, notes, and snippets.

@cogas
Last active October 18, 2020 14:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cogas/c89918d0c3f085d2116b to your computer and use it in GitHub Desktop.
Save cogas/c89918d0c3f085d2116b to your computer and use it in GitHub Desktop.
tkinter使ってダイアログからファイル名を取得できる
def fileopen ():
import tkinter
import tkinter.filedialog
tk = tkinter.Tk()
tk.withdraw()
args = {"initialdir" : "c:", "filetypes" : [("テキストファイル", "*.txt")], "title": "ファイル選択"}
name = tkinter.filedialog.askopenfilename(**args)
return name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment