โดย Jom07 » 22/02/2018 5:16 pm
การใช้งาน Python GUI (Tkinter) : การ Browse file (การค้นหาไฟล์)
เป็นการ browse หาไฟล์ที่ต้องการเรียกใช้งาน
ตัวอย่าง
โค้ด: เลือกทั้งหมด
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)
ผลรัน
เมื่อกดรันจะมีหน้าต่างขึ้นมาให้เราค้นหาไฟล์
[b]การใช้งาน Python GUI (Tkinter) : การ Browse file (การค้นหาไฟล์) [/b]
เป็นการ browse หาไฟล์ที่ต้องการเรียกใช้งาน
[b]ตัวอย่าง[/b]
[code]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)
[/code]
[b]ผลรัน[/b]
[img]http://snap.mindphp.com/index.php?view=2018Feb22_5a8e950c79612[/img]
[b]เมื่อกดรันจะมีหน้าต่างขึ้นมาให้เราค้นหาไฟล์[/b]