예제 #1
0
def askopendirnames(parent=None, title=_("Open"), **kwargs):
    """
    Return () or the tuple of the absolute paths of the chosen directories

    Options:
        * initialdir: initial folder whose content is displayed
        * initialfile: initial selected item (just the name, not the full path)
        * filetypes: [('name', '*.ext1|*.ext2|..'), ...]
          show only files of given filetype ("*" for all files)
        * okbuttontext: text displayed on the validate button, if None, the
          default text corresponding to the mode is used (either Open or Save)
        * cancelbuttontext: text displayed on the button that cancels the
          selection.
        * foldercreation: enable the user to create new folders if True (default)
    """
    dialog = FileBrowser(parent,
                         mode="opendir",
                         multiple_selection=True,
                         title=title,
                         **kwargs)
    dialog.wait_window(dialog)
    res = dialog.get_result()
    if not res:  # type consistency: always return a tuple
        res = ()
    return res
예제 #2
0
def askopendirnames(parent=None, title=_("Open"), **kwargs):
    """
    Return :obj:`()` 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 :obj:`[("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:
          :obj:`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)
    """
    dialog = FileBrowser(parent,
                         mode="opendir",
                         multiple_selection=True,
                         title=title,
                         **kwargs)
    dialog.wait_window(dialog)
    res = dialog.get_result()
    if not res:  # type consistency: always return a tuple
        res = ()
    return res
예제 #3
0
def asksaveasfilename(parent=None, title=_("Save As"), **kwargs):
    """
    Return '' or the chosen absolute path (the file might not exist)

    Options:
        * initialdir: initial folder whose content is displayed
        * initialfile: initial selected item (just the name, not the full path)
        * defaultext (save mode only): extension added to filename if none is given
        * filetypes: [('name', '*.ext1|*.ext2|..'), ...]
          show only files of given filetype ("*" for all files)
        * okbuttontext: text displayed on the validate button, if None, the
          default text corresponding to the mode is used (either Open or Save)
        * cancelbuttontext: text displayed on the button that cancels the
          selection.
        * foldercreation: enable the user to create new folders if True (default)
    """
    dialog = FileBrowser(parent, mode="save", title=title, **kwargs)
    dialog.wait_window(dialog)
    return dialog.get_result()
예제 #4
0
def asksaveasfilename(parent=None, title=_("Save As"), **kwargs):
    """
    Return :obj:`''` or the chosen 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 :obj:`[("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:
          :obj:`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)
    """
    dialog = FileBrowser(parent, mode="save", title=title, **kwargs)
    dialog.wait_window(dialog)
    return dialog.get_result()