wx.GenericDirCtrl¶
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.
Window Styles¶
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.
Events Emitted by this Class¶
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.
Class Hierarchy¶
Control Appearance¶
Methods Summary¶
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. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.GenericDirCtrl(Control)¶
Possible constructors:
GenericDirCtrl() -> None GenericDirCtrl(parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE, filter='', defaultFilter=0, name=TreeCtrlNameStr) -> None
This control can be used to place a directory listing (with optional files) on an arbitrary window.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
- Return type:
None
__init__ (self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE, filter=’’, defaultFilter=0, name=TreeCtrlNameStr)
Main constructor.
- Parameters:
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.
- Return type:
None
- CollapsePath(self, path)¶
Collapse the given path.
- Parameters:
path (string)
- Return type:
bool
- CollapseTree(self)¶
Collapses the entire tree.
- Return type:
None
- 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.
- Parameters:
path (string)
- Return type:
bool
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
- GetDefaultPath(self)¶
Gets the default path.
- Return type:
str
- GetFilePath(self)¶
Gets selected filename path only (else empty string).
This function doesn’t count a directory as a selection.
- Return type:
str
- GetFilePaths(self, paths)¶
Fills the array paths with the currently selected filepaths.
This function doesn’t count a directory as a selection.
- Parameters:
paths (list of strings)
- Return type:
None
- GetFilter(self)¶
Returns the filter string.
- Return type:
str
- GetFilterIndex(self)¶
Returns the current filter index (zero-based).
- Return type:
int
- GetFilterListCtrl(self)¶
Returns a pointer to the filter list control (if present).
- Return type:
- GetPath(self, *args, **kw)¶
-
GetPath (self)
Gets the currently-selected directory or filename.
- Return type:
str
GetPath (self, itemId)
Gets the path corresponding to the given tree control item.
- Parameters:
itemId (wx.TreeItemId)
- Return type:
str
Added in version 2.9.5.
- GetPaths(self)¶
Returns a list of the currently selected paths.
- Return type:
List[str]
- GetRootId(self)¶
Returns the root id for the tree control.
- Return type:
- GetTreeCtrl(self)¶
Returns a pointer to the tree control.
- Return type:
- Init(self)¶
Initializes variables.
- Return type:
None
- ReCreateTree(self)¶
Collapse and expand the tree, thus re-creating it from scratch.
May be used to update the displayed directory content.
- Return type:
None
- 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
isFalse
. Existing selections are not changed. Only visible items can be (de)selected, otherwise useExpandPath
.- Parameters:
path (string)
select (bool)
- Return type:
None
- SelectPaths(self, paths)¶
Selects only the specified paths, clearing any previous selection.
Only supported when
wx.DIRCTRL_MULTIPLE
is set.- Parameters:
paths (list of strings)
- Return type:
None
- SetDefaultPath(self, path)¶
Sets the default path.
- Parameters:
path (string)
- Return type:
None
- SetFilter(self, filter)¶
Sets the filter string.
- Parameters:
filter (string)
- Return type:
None
- SetFilterIndex(self, n)¶
Sets the current filter index (zero-based).
- Parameters:
n (int)
- Return type:
None
- SetPath(self, path)¶
Sets the current path.
- Parameters:
path (string)
- Return type:
None
- ShowHidden(self, show)¶
- Parameters:
show (bool) – If
True
, hidden folders and files will be displayed by the control. IfFalse
, they will not be displayed.- Return type:
None
- UnselectAll(self)¶
Removes the selection from all currently selected items.
- Return type:
None
Properties¶
- DefaultPath¶
See
GetDefaultPath
andSetDefaultPath
- FilePath¶
See
GetFilePath
- FilterIndex¶
See
GetFilterIndex
andSetFilterIndex
- FilterListCtrl¶
- TreeCtrl¶
See
GetTreeCtrl