Table Of Contents

Previous topic

FileConfig

Next topic

FileCtrlEvent

This Page

phoenix_title FileCtrl

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.

styles Window Styles

This class supports the following styles:

  • FC_DEFAULT_STYLE: The default style: FC_OPEN
  • FC_OPEN: Creates an file control suitable for opening files. Cannot be combined with FC_SAVE.
  • FC_SAVE: Creates an file control suitable for saving files. Cannot be combined with FC_OPEN.
  • FC_MULTIPLE: For open control only, Allows selecting multiple files. Cannot be combined with FC_SAVE
  • FC_NOSHOWHIDDEN: Hides the “Show Hidden Files” checkbox (Generic only)

events Events Emitted by this Class

Handlers bound for the following event types will receive a 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.

See also

GenericDirCtrl


class_hierarchy Inheritance Diagram

Inheritance diagram for class FileCtrl

Inheritance diagram of FileCtrl


appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__  
Create Create function for two-step construction.
GetDirectory Returns the current directory of the file control (i.e.
GetFilename Returns the currently selected filename.
GetFilterIndex Returns the zero-based index of the currently selected filter.
GetPath Returns the full path (directory and filename) of the currently selected file.
GetWildcard Returns the current wildcard.
SetDirectory Sets(changes) the current directory displayed in the control.
SetFilename Selects a certain file.
SetFilterIndex Sets the current filter index, starting from zero.
SetPath Changes to a certain directory and selects a certain file.
SetWildcard Sets the wildcard, which can contain multiple file types, for example: “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”.
ShowHidden Sets whether hidden files and folders are shown or not.

api Class API



class FileCtrl(Control)

This control allows the user to select a file.

Possible constructors:

FileCtrl()

FileCtrl(parent, id=ID_ANY, defaultDirectory='',
         defaultFilename='', wildCard=FileSelectorDefaultWildcardStr,
         style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize,
         name=FileCtrlNameStr)

Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)



__init__ (self, parent, id=ID_ANY, defaultDirectory=’‘, defaultFilename=’‘, wildCard=FileSelectorDefaultWildcardStr, style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize, name=FileCtrlNameStr)

Constructs the window.

Parameters:
  • parent (Window) – Parent window, must not be not None.
  • id (int) – 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 ”.” or “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”.
  • style (long) – The window style, see FC_ flags.
  • pos (Point) – Initial position.
  • size (Size) – Initial size.
  • name (string) – Control name.
Returns:

True if the control was successfully created or False if creation failed.





Create(self, parent, id=ID_ANY, defaultDirectory='', defaultFilename='', wildCard=FileSelectorDefaultWildcardStr, style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize, name=FileCtrlNameStr)

Create function for two-step construction.

See FileCtrl for details.

Parameters:
  • parent (Window) –
  • id (int) –
  • defaultDirectory (string) –
  • defaultFilename (string) –
  • wildCard (string) –
  • style (long) –
  • pos (Point) –
  • size (Size) –
  • name (string) –
Return type:

bool



GetDirectory(self)

Returns the current directory of the file control (i.e.

the directory shown by it).

Return type:string


GetFilename(self)

Returns the currently selected filename.

For the controls having the FC_MULTIPLE style, use GetFilenames instead.

Return type:string


GetFilterIndex(self)

Returns the zero-based index of the currently selected filter.

Return type: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.

Return type:string


GetWildcard(self)

Returns the current wildcard.

Return type:string


SetDirectory(self, directory)

Sets(changes) the current directory displayed in the control.

Parameters:directory (string) –
Return type:bool
Returns:Returns True on success, False otherwise.


SetFilename(self, filename)

Selects a certain file.

Parameters:filename (string) –
Return type:bool
Returns:Returns True on success, False otherwise


SetFilterIndex(self, filterIndex)

Sets the current filter index, starting from zero.

Parameters:filterIndex (int) –


SetPath(self, path)

Changes to a certain directory and selects a certain file.

In case the filename specified isn’t found/couldn’t be shown with currently selected filter, False is returned.

Parameters:path (string) –
Return type:bool
Returns:Returns True on success, False otherwise


SetWildcard(self, wildCard)

Sets the wildcard, which can contain multiple file types, for example: “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”.

Parameters:wildCard (string) –


ShowHidden(self, show)

Sets whether hidden files and folders are shown or not.

Parameters:show (bool) –

Properties



Directory

See GetDirectory and SetDirectory



Filename

See GetFilename and SetFilename



Filenames

See GetFilenames



FilterIndex

See GetFilterIndex and SetFilterIndex



Path

See GetPath and SetPath



Paths

See GetPaths



Wildcard

See GetWildcard and SetWildcard