This control can be used to place a directory listing (with optional files) on an arbitrary window.
The control contains a wx.TreeCtrl window representing the directory hierarchy, and optionally, a wx.Choice window containing a list of filters.
^^
This class supports the following styles:
wx.DIRCTRL_DIR_ONLY
: Only show directories, and not files.
wx.DIRCTRL_3D_INTERNAL
: Use 3D borders for internal controls. This is the default.
wx.DIRCTRL_SELECT_FIRST
: When setting the default path, select the first file in the directory.
wx.DIRCTRL_SHOW_FILTERS
: Show the drop-down filter list.
wx.DIRCTRL_EDIT_LABELS
: Allow the folder and file labels to be editable.
wx.DIRCTRL_MULTIPLE
: Allows multiple files and folders to be selected. ^^
^^
Event macros for events emitted by this class:
EVT_DIRCTRL_SELECTIONCHANGED: Selected directory has changed. Processes a wxEVT_DIRCTRL_SELECTIONCHANGED
event type. Notice that this event is generated even for the changes done by the program itself and not only those done by the user. Available since wxWidgets 2.9.5.
EVT_DIRCTRL_FILEACTIVATED: The user activated a file by double-clicking or pressing Enter. Available since wxWidgets 2.9.5. ^^
Default constructor. |
|
Collapse the given path. |
|
Collapses the entire tree. |
|
Create function for two-step construction. |
|
Tries to expand as much of the given path as possible, so that the filename or directory is visible in the tree control. |
|
Gets the default path. |
|
Gets selected filename path only (else empty string). |
|
Fills the array paths with the currently selected filepaths. |
|
Returns the filter string. |
|
Returns the current filter index (zero-based). |
|
Returns a pointer to the filter list control (if present). |
|
Gets the currently-selected directory or filename. |
|
Returns a list of the currently selected paths. |
|
Returns the root id for the tree control. |
|
Returns a pointer to the tree control. |
|
Initializes variables. |
|
Collapse and expand the tree, thus re-creating it from scratch. |
|
Selects the given item. |
|
Selects only the specified paths, clearing any previous selection. |
|
Sets the default path. |
|
Sets the filter string. |
|
Sets the current filter index (zero-based). |
|
Sets the current path. |
|
Removes the selection from all currently selected items. |
See |
|
See |
|
See |
|
See |
|
See |
|
See |
wx.
GenericDirCtrl
(Control)¶Possible constructors:
GenericDirCtrl()
GenericDirCtrl(parent, id=ID_ANY, dir=DirDialogDefaultFolderStr,
pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE,
filter="", defaultFilter=0, name=TreeCtrlNameStr)
This control can be used to place a directory listing (with optional files) on an arbitrary window.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE, filter=””, defaultFilter=0, name=TreeCtrlNameStr)
Main constructor.
parent (wx.Window) – Parent window.
id (wx.WindowID) – Window identifier.
dir (string) – Initial folder.
pos (wx.Point) – Position.
size (wx.Size) – Size.
style (long) – Window style. Please see wx.GenericDirCtrl for a list of possible styles.
filter (string) – A filter string, using the same syntax as that for wx.FileDialog. This may be empty if filters are not being used. Example: "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
defaultFilter (int) – The zero-indexed default filter setting.
name (string) – The window name.
CollapsePath
(self, path)¶Collapse the given path.
path (string) –
bool
CollapseTree
(self)¶Collapses the entire tree.
Create
(self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE, filter="", defaultFilter=0, name=TreeCtrlNameStr)¶Create function for two-step construction.
See wx.GenericDirCtrl for details.
ExpandPath
(self, path)¶Tries to expand as much of the given path as possible, so that the filename or directory is visible in the tree control.
path (string) –
bool
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetDefaultPath
(self)¶Gets the default path.
string
GetFilePath
(self)¶Gets selected filename path only (else empty string).
This function doesn’t count a directory as a selection.
string
GetFilePaths
(self, paths)¶Fills the array paths with the currently selected filepaths.
This function doesn’t count a directory as a selection.
paths (list of strings) –
GetFilter
(self)¶Returns the filter string.
string
GetFilterIndex
(self)¶Returns the current filter index (zero-based).
int
GetFilterListCtrl
(self)¶Returns a pointer to the filter list control (if present).
GetPath
(self, *args, **kw)¶GetPath (self)
Gets the currently-selected directory or filename.
string
GetPath (self, itemId)
Gets the path corresponding to the given tree control item.
itemId (wx.TreeItemId) –
string
New in version 2.9.5.
GetPaths
(self)¶Returns a list of the currently selected paths.
list
GetRootId
(self)¶Returns the root id for the tree control.
GetTreeCtrl
(self)¶Returns a pointer to the tree control.
Init
(self)¶Initializes variables.
ReCreateTree
(self)¶Collapse and expand the tree, thus re-creating it from scratch.
May be used to update the displayed directory content.
SelectPath
(self, path, select=True)¶Selects the given item.
In multiple selection controls, can be also used to deselect a currently selected item if the value of select
is False
. Existing selections are not changed. Only visible items can be (de)selected, otherwise use ExpandPath
.
path (string) –
select (bool) –
SelectPaths
(self, paths)¶Selects only the specified paths, clearing any previous selection.
Only supported when wx.DIRCTRL_MULTIPLE
is set.
paths (list of strings) –
SetDefaultPath
(self, path)¶Sets the default path.
path (string) –
SetFilter
(self, filter)¶Sets the filter string.
filter (string) –
SetFilterIndex
(self, n)¶Sets the current filter index (zero-based).
n (int) –
SetPath
(self, path)¶Sets the current path.
path (string) –
ShowHidden
(self, show)¶show (bool) – If True
, hidden folders and files will be displayed by the control. If False
, they will not be displayed.
UnselectAll
(self)¶Removes the selection from all currently selected items.
DefaultPath
¶See GetDefaultPath
and SetDefaultPath
FilePath
¶See GetFilePath
FilterIndex
¶See GetFilterIndex
and SetFilterIndex
FilterListCtrl
¶TreeCtrl
¶See GetTreeCtrl