Displaying file browser to upload read file path in Tkinter window using filedialog askopenfilename

plus2net
plus2net
14.4 هزار بار بازدید - 3 سال پیش -
www.plus2net.com/python/tkinter-filedialog-askopen… We can present the user file browser window asking them to select any file for uploading or reading by the system. For this we will import the filedialog module and use the askopenfilename and askopenfile function. Initialdir We can specify the option initialdir to show the default directory to the user once the file dialog box is open. User can change this directory and browse to different location for selecting the file. filetypes We can specify type of file extensions allowed to upload and those file types will be visible to the user inside the directory for selection. file = filedialog.askopenfilename(initialdir='D:\\my_data\\my_html\\', title='Upload to plus2net',filetypes=[("CSV files", ".csv")]) displaying file output in console We can read the content of the file and display the data in the console. Displaying File path After reading the file name with path by using the function askopenfinename() we can display the file name by using StringVar() connected to a Label. #askopenfilename() #askopenfile() #filedialog #tkinterbrowsefile #filebrowser #readfilepath #tkinter #tkintertutorials #plus2net
3 سال پیش در تاریخ 1400/02/25 منتشر شده است.
14,491 بـار بازدید شده
... بیشتر