![]() ![]() Root.filename = tkFileDialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (( "jpeg files", "*.jpg"),( "all files", "*.*"))) Import Tkinter, Tkconstants, tkFileDialog Python 2.7 version: from Tkinter import * from Tkinter import * On a Windows machine change the initialdir to “C:\”. If a user presses cancel the filename is empty. The code below will simply show the dialog and return the filename. Tkinter.tk.askopenfilename is an extension of the askopenfilename function provided in Tcl/Tk. The extensions are shown in the bottom of the form (Files of type). The askopenfilename function to creates an file dialog object. The main problem is that there is no simple example of how to do it. Tkinter file dialogs are easy to use, but not that easy to find out how to use. Dialogs included in tkinter let you ask for a filename or directory. The code is displayed here along with screenshots. This page is a collection of python tkinter file dialogs. Instead of implementing those in Tkinter GUI on your own. TkFileDialog is a module with open and save dialog functions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |