This control allows the user to select a file.
Two implementations of this class exist, one for Gtk and another generic one for all the other ports.
This class is only available if USE_FILECTRL
is set to 1.
^^
This class supports the following styles:
wx.FC_DEFAULT_STYLE
: The default style: wx.FC_OPEN
wx.FC_OPEN
: Creates an file control suitable for opening files. Cannot be combined with wx.FC_SAVE
.
wx.FC_SAVE
: Creates an file control suitable for saving files. Cannot be combined with wx.FC_OPEN
.
wx.FC_MULTIPLE
: For open control only, Allows selecting multiple files. Cannot be combined with wx.FC_SAVE
wx.FC_NOSHOWHIDDEN
: Hides the “Show Hidden Files” checkbox (Generic only) ^^
^^
Handlers bound for the following event types will receive a wx.FileCtrlEvent parameter.
EVT_FILECTRL_FILEACTIVATED: The user activated a file(by double-clicking or pressing Enter)
EVT_FILECTRL_SELECTIONCHANGED: The user changed the current selection(by selecting or deselecting a file)
EVT_FILECTRL_FOLDERCHANGED: The current folder of the file control has been changed
EVT_FILECTRL_FILTERCHANGED: The current file filter of the file control has been changed.
New in version 2.9.1..
Implementations:GTK port; a generic implementation is used elsewhere.
Create function for two-step construction. |
|
Returns the current directory of the file control (i.e. the directory shown by it). |
|
Returns the currently selected filename. |
|
Returns a list of filenames selected in the control. This function |
|
Returns the zero-based index of the currently selected filter. |
|
Returns the full path (directory and filename) of the currently selected file. |
|
Returns a list of the full paths (directory and filename) of the files |
|
Returns the current wildcard. |
|
Sets(changes) the current directory displayed in the control. |
|
Selects a certain file. |
|
Sets the current filter index, starting from zero. |
|
Changes to a certain directory and selects a certain file. |
|
Sets the wildcard, which can contain multiple file types, for example: “ |
|
Sets whether hidden files and folders are shown or not. |
See |
|
See |
|
See |
|
See |
|
See |
|
See |
wx.
FileCtrl
(Control)¶Possible constructors:
FileCtrl() -> None
FileCtrl(parent : Window, id: int=ID_ANY, defaultDirectory: str='',
defaultFilename: str='', wildCard: str=FileSelectorDefaultWildcardStr,
style: int=FC_DEFAULT_STYLE, pos: Point=DefaultPosition, size:
Size=DefaultSize, name: str=FileCtrlNameStr) -> None
This control allows the user to select a file.
__init__
(self, *args, **kw)¶__init__ (self)
None
__init__ (self, parent : Window, id: int=ID_ANY, defaultDirectory: str=’’, defaultFilename: str=’’, wildCard: str=FileSelectorDefaultWildcardStr, style: int=FC_DEFAULT_STYLE, pos: Point=DefaultPosition, size: Size=DefaultSize, name: str=FileCtrlNameStr)
Constructs the window.
parent (wx.Window) – Parent window, must not be not None
.
id (wx.WindowID) – The identifier for the control.
defaultDirectory (string) – The initial directory shown in the control. Must be a valid path to a directory or the empty string. In case it is the empty string, the current working directory is used.
defaultFilename (string) – The default filename, or the empty string.
wildCard (string) – A wildcard specifying which files can be selected, such as “x.x” or “BMP
files (.bmp)|.bmp|GIF files (.gif)|.gif”.
style (long) – The window style, see FC_
flags.
pos (wx.Point) – Initial position.
size (wx.Size) – Initial size.
name (string) – Control name.
None
Create
(self, parent : Window, id: int=ID_ANY, defaultDirectory: str='', defaultFilename: str='', wildCard: str=FileSelectorDefaultWildcardStr, style: int=FC_DEFAULT_STYLE, pos: Point=DefaultPosition, size: Size=DefaultSize, name: str=FileCtrlNameStr)¶Create function for two-step construction.
See wx.FileCtrl for details.
GetClassDefaultAttributes
(variant: WindowVariant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetDirectory
(self)¶Returns the current directory of the file control (i.e. the directory shown by it).
str
GetFilename
(self)¶Returns the currently selected filename.
For the controls having the FC_MULTIPLE
style, use GetFilenames
instead.
str
GetFilenames
(self)¶Returns a list of filenames selected in the control. This function should only be used with controls which have the wx.``wx.FC_MULTIPLE`` style, use GetFilename for the others.
List[str]
GetFilterIndex
(self)¶Returns the zero-based index of the currently selected filter.
int
GetPath
(self)¶Returns the full path (directory and filename) of the currently selected file.
For the controls having the FC_MULTIPLE
style, use GetPaths
instead.
str
GetPaths
(self)¶Returns a list of the full paths (directory and filename) of the files chosen. This function should only be used with controlss which have the wx.``wx.FC_MULTIPLE`` style, use GetPath for the others.
List[str]
GetWildcard
(self)¶Returns the current wildcard.
str
SetDirectory
(self, directory : str)¶Sets(changes) the current directory displayed in the control.
directory (string) –
bool
Returns True
on success, False
otherwise.
SetFilename
(self, filename : str)¶Selects a certain file.
filename (string) –
bool
Returns True
on success, False
otherwise
SetFilterIndex
(self, filterIndex : int)¶Sets the current filter index, starting from zero.
filterIndex (int) –
None
SetPath
(self, path : str)¶Changes to a certain directory and selects a certain file.
If path includes the directory part, it must exist, otherwise False
is returned and nothing else is done.
path (string) –
bool
Returns True
on success, False
otherwise
SetWildcard
(self, wildCard : str)¶Sets the wildcard, which can contain multiple file types, for example: “BMP
files (.bmp)|.bmp|GIF files (.gif)|.gif”.
wildCard (string) –
None
ShowHidden
(self, show : bool)¶Sets whether hidden files and folders are shown or not.
show (bool) –
None
Directory
¶See GetDirectory
and SetDirectory
Filename
¶See GetFilename
and SetFilename
Filenames
¶See GetFilenames
FilterIndex
¶See GetFilterIndex
and SetFilterIndex
Wildcard
¶See GetWildcard
and SetWildcard