Documentation

askopendirname

tkfilebrowser.askopendirname(parent=None, title='Open', **kwargs)[source]

Return '' or the absolute path of the chosen directory.

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)

askopendirnames

tkfilebrowser.askopendirnames(parent=None, title='Open', **kwargs)[source]

Return () or the tuple of the absolute paths of the chosen directories

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)

askopenfilename

tkfilebrowser.askopenfilename(parent=None, title='Open', **kwargs)[source]

Return '' or the absolute path of the chosen file

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)

askopenfilenames

tkfilebrowser.askopenfilenames(parent=None, title='Open', **kwargs)[source]

Return () or the tuple of the absolute paths of the chosen files

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)

asksaveasfilename

tkfilebrowser.asksaveasfilename(parent=None, title='Save As', **kwargs)[source]

Return '' or the chosen absolute path (the file might not exist)

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
defaultext : str (e.g. ‘.png’)
extension added to filename if none is given (default is none)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)

FileBrowser

class tkfilebrowser.FileBrowser(parent, initialdir='', initialfile='', mode='openfile', multiple_selection=False, defaultext='', title='Filebrowser', filetypes=[], okbuttontext=None, cancelbuttontext='Cancel', foldercreation=True, **kw)[source]

Filebrowser dialog class.

__init__(parent, initialdir='', initialfile='', mode='openfile', multiple_selection=False, defaultext='', title='Filebrowser', filetypes=[], okbuttontext=None, cancelbuttontext='Cancel', foldercreation=True, **kw)[source]

Create a filebrowser dialog.

Arguments:

parent : Tk or Toplevel instance
parent window
title : str
the title of the filebrowser window
initialdir : str
directory whose content is initially displayed
initialfile : str
initially selected item (just the name, not the full path)
mode : str
kind of dialog: “openfile”, “opendir” or “save”
multiple_selection : bool
whether to allow multiple items selection (open modes only)
defaultext : str (e.g. ‘.png’)
extension added to filename if none is given (default is none)
filetypes : list [("name", "*.ext1|*.ext2|.."), ...]
only the files of given filetype will be displayed, e.g. to allow the user to switch between displaying only PNG or JPG pictures or dispalying all files: filtypes=[("Pictures", "*.png|*.PNG|*.jpg|*.JPG'), ("All files", "*")]
okbuttontext : str
text displayed on the validate button, default is “Open”.
cancelbuttontext : str
text displayed on the button that cancels the selection, default is “Cancel”.
foldercreation : bool
enable the user to create new folders if True (default)
create_folder(event=None)[source]

Create new folder in current location.

get_result()[source]

Return selection.

move_item(item, index)[source]

Move item to index and update dark/light line alternance.

quit()[source]

Destroy dialog.

toggle_hidden(event=None)[source]

Toggle the visibility of hidden files/folders.

toggle_path_entry(event)[source]

Toggle visibility of path entry.

validate(event=None)[source]

Validate selection and store it in self.results if valid.