phoenix_title wx.FilePickerCtrl

This control allows the user to select a file.

The generic implementation is a button which brings up a wx.FileDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the file-chooser dialog. It is only available if USE_FILEPICKERCTRL is set to 1 (the default).

^^

styles Window Styles

This class supports the following styles:

  • wx.FLP_DEFAULT_STYLE: The default style: includes wx.FLP_OPEN | wx.FLP_FILE_MUST_EXIST and, under wxMSW and wxOSX, wx.FLP_USE_TEXTCTRL.

  • wx.FLP_USE_TEXTCTRL: Creates a text control to the left of the picker button which is completely managed by the wx.FilePickerCtrl and which can be used by the user to specify a path (see SetPath). The text control is automatically synchronized with button’s value. Use functions defined in wx.PickerBase to modify the text control.

  • wx.FLP_OPEN: Creates a picker which allows the user to select a file to open.

  • wx.FLP_SAVE: Creates a picker which allows the user to select a file to save.

  • wx.FLP_OVERWRITE_PROMPT: Can be combined with wx.FLP_SAVE only: ask confirmation to the user before selecting a file.

  • wx.FLP_FILE_MUST_EXIST: Can be combined with wx.FLP_OPEN only: the file selected in the popup wx.FileDialog must be an existing file. Notice that it still remains possible for the user to enter a non-existent file name in the text control if FLP_USE_TEXTCTRL is also used, this flag is a hint for the user rather than a guarantee that the selected file does exist for the program.

  • wx.FLP_CHANGE_DIR: Change current working directory on each user file selection change.

  • wx.FLP_SMALL: Use smaller version of the control with a small “…” button instead of the normal “Browse” one. This flag is new since wxWidgets 2.9.3. ^^

^^

events Events Emitted by this Class

Handlers bound for the following event types will receive a wx.FileDirPickerEvent parameter.

  • EVT_FILEPICKER_CHANGED: The user changed the file selected in the control either using the button or using text control (see wx.FLP_USE_TEXTCTRL; note that in this case the event is fired only if the user’s input is valid, e.g. an existing file path if wx.FLP_FILE_MUST_EXIST was given). ^^


class_hierarchy Class Hierarchy

Inheritance diagram for class FilePickerCtrl:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__

Create

Creates this widget with the given parameters.

GetClassDefaultAttributes

GetPath

Returns the absolute path of the currently selected file.

SetInitialDirectory

Set the directory to show when starting to browse for files.

SetPath

Sets the absolute path of the currently selected file.


property_summary Properties Summary

Path

See GetPath and SetPath


api Class API

class wx.FilePickerCtrl(PickerBase)

Possible constructors:

FilePickerCtrl()

FilePickerCtrl(parent, id=ID_ANY, path="",
               message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr,
               pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE,
               validator=DefaultValidator, name=FilePickerCtrlNameStr)

This control allows the user to select a file.


Methods

__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)



__init__ (self, parent, id=ID_ANY, path=””, message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr, pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE, validator=DefaultValidator, name=FilePickerCtrlNameStr)

Initializes the object and calls Create with all the parameters.

Parameters
  • parent (wx.Window) –

  • id (wx.WindowID) –

  • path (string) –

  • message (string) –

  • wildcard (string) –

  • pos (wx.Point) –

  • size (wx.Size) –

  • style (long) –

  • validator (wx.Validator) –

  • name (string) –





Create(self, parent, id=ID_ANY, path="", message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr, pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE, validator=DefaultValidator, name=FilePickerCtrlNameStr)

Creates this widget with the given parameters.

Parameters
  • parent (wx.Window) – Parent window, must not be not None.

  • id (wx.WindowID) – The identifier for the control.

  • path (string) – The initial file shown in the control. Must be a valid path to a file or the empty string.

  • message (string) – The message shown to the user in the wx.FileDialog shown by the control.

  • wildcard (string) – A wildcard which defines user-selectable files (use the same syntax as for wx.FileDialog’s wildcards).

  • pos (wx.Point) – Initial position.

  • size (wx.Size) – Initial size.

  • style (long) – The window style, see FLP_ flags.

  • validator (wx.Validator) – Validator which can be used for additional data checks.

  • name (string) – Control name.

Return type

bool

Returns

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



static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)
Parameters

variant (WindowVariant) –

Return type

wx.VisualAttributes



GetPath(self)

Returns the absolute path of the currently selected file.

Return type

string



SetInitialDirectory(self, dir)

Set the directory to show when starting to browse for files.

This function is mostly useful for the file picker controls which have no selection initially to configure the directory that should be shown if the user starts browsing for files as otherwise the directory of initially selected file is used, which is usually the desired behaviour and so the directory specified by this function is ignored in this case.

Parameters

dir (string) –

New in version 2.9.4.



SetPath(self, filename)

Sets the absolute path of the currently selected file.

If the control uses FLP_FILE_MUST_EXIST and does not use FLP_USE_TEXTCTRL style, the filename must be a name of an existing file and will be simply ignored by the native wxGTK implementation if this is not the case (the generic implementation used under the other platforms accepts even invalid file names currently, but this is subject to change in the future, don’t rely on being able to use non-existent paths with it).

Parameters

filename (string) –


Properties

Path

See GetPath and SetPath