การใช้งาน Python GUI (Tkinter) : การ Browse file (การค้นหาไฟล์)

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Python GUI (Tkinter) : การ Browse file (การค้นหาไฟล์)

การใช้งาน Python GUI (Tkinter) : การ Browse file (การค้นหาไฟล์)

โดย 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)
ผลรัน
รูปภาพ
เมื่อกดรันจะมีหน้าต่างขึ้นมาให้เราค้นหาไฟล์

ข้างบน