Create a File Dialog by calling dialog.fileDialog with the arguments shown in the following table.
Argument |
Data type/notes |
self |
the window (background) that is the parent for
the dialog |
message |
quoted string defining the title for the dialog |
path |
quoted string defining the default path to be used for the dialog |
fileName |
quoted string defining a file name to be used typically in saving a file |
filter |
quoted string containing the pattern to be used to identify
files to be shown to the user by default when the File Dialog opens. The
dialog above was created with a pattern of "*.py." A more complex example
is shown below. |
OPTIONAL style |
A boolean logic expression containing one or more pre-defined window style constants that define how the window will look and behave. |
result = dialog.fileDialog(self, 'Open', '', '', wildcard )
after setting the variable wildcard to the string "*.py".The optional style argument in dialog.fileDialog is generally not used when opening a File dialog to save a document because its default settings -- wx.OPEN | wx.MULTIPLE -- is the generally accepted norm for such dialogs. In creating dialogs for saving files, on the other hand, it is often useful to define a variable (here called "aStyle") which defines more fully how the save process will be managed. For example:
aStyle = wx.SAVE | wx.HIDE_READONLY | wx.OVERWRITE_PROMPT
will create a file save dialog (rather than the default file open), in which read-only files are not shown and an attempt to overwrite an existing file is confirmed with a prompt dialog.
Name of value |
Description |
accepted |
True = user clicked OK False = user clicked Cancel |
paths |
list of strings containing the full pathnames
to all files selected by the user |