ฟังก์ชัน tkFileDialog
(1) .askopenfile เป็นการเปิดไฟล์ เลือกแฟ้มไดอะล็อกที่มีอยู่
(2) .asksaveasfilename เป็นการบันทึกไฟล์ ไดอะล็อกที่ต้องการสร้างหรือเปลี่ยนไฟล์
(3) .askdirectory เป็นการเปิดไดเรกทอรี
เช่น ตัวอย่างโค้ดในการใช้ python 3
โค้ด: เลือกทั้งหมด
from tkinter import filedialog
from tkinter import *
root = Tk()
root.filename = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("files","*.exe"),("all files","*.*")))
print (root.filename)
จะขึ้นกล่องเพื่อให้เลิกไฟล์ที่เราต้องการเลือกใช้
บทเรียน PythonTK เพิ่มเติม
https://www.mindphp.com/%E0%B8%9A%E0%B8 ... n-gui.html