Python GUI open a file (filedialog) 📁

Bro Code
Bro Code
93.1 هزار بار بازدید - 4 سال پیش - Python GUI filedialog tkinter open
Python GUI filedialog tkinter open a file tutorial for beginners

#Python #GUI #filedialog #tkinter #open #file #tutorial #beginners

from tkinter import *
from tkinter import filedialog

def openFile():
   filepath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main",
                                         title="Open file okay?",
                                         filetypes= (("text files","*.txt"),
                                         ("all files","*.*")))
   file = open(filepath,'r')
   print(file.read())
   file.close()

window = Tk()
button = Button(text="Open",command=openFile)
button.pack()
window.mainloop()
4 سال پیش در تاریخ 1399/05/20 منتشر شده است.
93,153 بـار بازدید شده
... بیشتر