pyface.i_file_dialog module

The interface for a dialog that allows the user to open/save files etc.

class pyface.i_file_dialog.IFileDialog(adaptee, default=<class 'traits.adaptation.adaptation_error.AdaptationError'>)[source]

Bases: IDialog

The interface for a dialog that allows the user to open/save files etc.

action = Enum("open", "open files", "save as")

The ‘action’ that the user is peforming on the directory (“open files” differs from “open” in that the former supports multiple selections).

default_directory = Str()

The default directory.

default_filename = Str()

The default filename.

default_path = Str()

The default path (directory and filename) of the chosen file. This is only used when the default_directory and default_filename are not set and is equivalent to setting both.

directory = Str()

The directory containing the chosen file.

filename = Str()

The name (basename only) of the chosen file.

path = Str()

The path (directory and filename) of the chosen file. To be used when only single selection is allowed: if action is “open files”, use paths instead.

paths = List(Str())

The paths (directory and filename) of the chosen files. To be used when multiple selection is allowed.

wildcard = Str()

The wildcard used to restrict the set of files.

wildcard_index = Int(0)

The index of the selected wildcard.

class pyface.i_file_dialog.MFileDialog[source]

Bases: HasTraits

The mixin class that contains common code for toolkit specific implementations of the IFileDialog interface.

Implements: create_wildcard()

WILDCARD_PY = 'Python files (*.py)|*.py|'

A file dialog wildcard for Python files.

WILDCARD_TXT = 'Text files (*.txt)|*.txt|'

A file dialog wildcard for text files.

WILDCARD_ALL = 'All files (*)|*'
WILDCARD_ZIP = 'Zip files (*.zip)|*.zip|'

A file dialog wildcard for Zip archives.

classmethod create_wildcard(description, extension)[source]

Creates a wildcard for a given extension.

Parameters
  • description (str) – A human-readable description of the pattern.

  • extenstion (list) – The wildcard patterns for the extension.