This control allows the user to select a directory.
The generic implementation is a button which brings up a wx.DirDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the dir-chooser dialog. It is only available if USE_DIRPICKERCTRL
is set to 1 (the default).
This class supports the following styles:
wx.DIRP_DEFAULT_STYLE
: The default style: includes wx.DIRP_DIR_MUST_EXIST
and, under wxMSW only, wx.DIRP_USE_TEXTCTRL
.wx.DIRP_USE_TEXTCTRL
: Creates a text control to the left of the picker button which is completely managed by the wx.DirPickerCtrl 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.DIRP_DIR_MUST_EXIST
: Creates a picker which allows to select only existing directories. wxGTK control always adds this flag internally as it does not support its absence.wx.DIRP_CHANGE_DIR
: Change current working directory on each user directory selection change.wx.DIRP_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.Handlers bound for the following event types will receive a wx.FileDirPickerEvent parameter.
wx.DIRP_USE_TEXTCTRL
; note that in this case the event is fired only if the user’s input is valid, e.g. an existing directory path).See also
__init__ |
|
Create |
Creates the widgets with the given parameters. |
GetPath |
Returns the absolute path of the currently selected directory. |
SetInitialDirectory |
Set the directory to show when starting to browse for directories. |
SetPath |
Sets the absolute path of the currently selected directory (the default converter uses current locale’s charset). |
wx.
DirPickerCtrl
(PickerBase)¶Possible constructors:
DirPickerCtrl()
DirPickerCtrl(parent, id=ID_ANY, path="",
message=DirSelectorPromptStr, pos=DefaultPosition, size=DefaultSize,
style=DIRP_DEFAULT_STYLE, validator=DefaultValidator,
name=DirPickerCtrlNameStr)
This control allows the user to select a directory.
__init__
(self, *args, **kw)¶__init__ (self)
__init__ (self, parent, id=ID_ANY, path=””, message=DirSelectorPromptStr, pos=DefaultPosition, size=DefaultSize, style=DIRP_DEFAULT_STYLE, validator=DefaultValidator, name=DirPickerCtrlNameStr)
Initializes the object and calls Create
with all the parameters.
Parameters: |
|
---|
Create
(self, parent, id=ID_ANY, path="", message=DirSelectorPromptStr, pos=DefaultPosition, size=DefaultSize, style=DIRP_DEFAULT_STYLE, validator=DefaultValidator, name=DirPickerCtrlNameStr)¶Creates the widgets with the given parameters.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
GetPath
(self)¶Returns the absolute path of the currently selected directory.
Return type: | string |
---|
SetInitialDirectory
(self, dir)¶Set the directory to show when starting to browse for directories.
This function is mostly useful for the directory picker controls which have no selection initially to configure the directory that should be shown if the user starts browsing for directories as otherwise the initially selected directory 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, dirname)¶Sets the absolute path of the currently selected directory (the default converter uses current locale’s charset).
This must be a valid directory if DIRP_DIR_MUST_EXIST
style was given.
Parameters: | dirname (string) – |
---|