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.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:
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.
Methods Summary¶__init__ |
Default constructor. |
CollapsePath |
Collapse the given path. |
CollapseTree |
Collapses the entire tree. |
Create |
Create function for two-step construction. |
ExpandPath |
Tries to expand as much of the given path as possible, so that the filename or directory is visible in the tree control. |
GetDefaultPath |
Gets the default path. |
GetFilePath |
Gets selected filename path only (else empty string). |
GetFilePaths |
Fills the array paths with the currently selected filepaths. |
GetFilter |
Returns the filter string. |
GetFilterIndex |
Returns the current filter index (zero-based). |
GetFilterListCtrl |
Returns a pointer to the filter list control (if present). |
GetPath |
Gets the currently-selected directory or filename. |
GetPaths |
Fills the array paths with the selected directories and filenames. |
GetRootId |
Returns the root id for the tree control. |
GetTreeCtrl |
Returns a pointer to the tree control. |
Init |
Initializes variables. |
ReCreateTree |
Collapse and expand the tree, thus re-creating it from scratch. |
SelectPath |
Selects the given item. |
SelectPaths |
Selects only the specified paths, clearing any previous selection. |
SetDefaultPath |
Sets the default path. |
SetFilter |
Sets the filter string. |
SetFilterIndex |
Sets the current filter index (zero-based). |
SetPath |
Sets the current path. |
ShowHidden |
|
UnselectAll |
Removes the selection from all currently selected items. |
Properties Summary¶DefaultPath |
See GetDefaultPath and SetDefaultPath |
FilePath |
See GetFilePath |
Filter |
See GetFilter and SetFilter |
FilterIndex |
See GetFilterIndex and SetFilterIndex |
FilterListCtrl |
See GetFilterListCtrl |
Path |
See GetPath and SetPath |
RootId |
See GetRootId |
TreeCtrl |
See GetTreeCtrl |
Class API¶wx.GenericDirCtrl(Control)¶Possible constructors:
GenericDirCtrl()
GenericDirCtrl(parent, id=ID_ANY, dir=DirDialogDefaultFolderStr,
pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_3D_INTERNAL,
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_3D_INTERNAL, filter=””, defaultFilter=0, name=TreeCtrlNameStr)
Main constructor.
| Parameters: |
|
|---|
CollapsePath(self, path)¶Collapse the given path.
| Parameters: | path (string) – |
|---|---|
| Return type: | bool |
CollapseTree(self)¶Collapses the entire tree.
Create(self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_3D_INTERNAL, filter="", defaultFilter=0, name=TreeCtrlNameStr)¶Create function for two-step construction.
See wx.GenericDirCtrl for details.
| Parameters: | |
|---|---|
| Return type: | bool |
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 |
GetDefaultPath(self)¶Gets the default path.
| Return type: | string |
|---|
GetFilePath(self)¶Gets selected filename path only (else empty string).
This function doesn’t count a directory as a selection.
| Return type: | string |
|---|
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) – |
|---|
GetFilter(self)¶Returns the filter string.
| Return type: | string |
|---|
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: | wx.DirFilterListCtrl |
|---|
GetPath(self, *args, **kw)¶GetPath (self)
Gets the currently-selected directory or filename.
| Return type: | string |
|---|
GetPath (self, itemId)
Gets the path corresponding to the given tree control item.
| Parameters: | itemId (wx.TreeItemId) – |
|---|---|
| Return type: | string |
New in version 2.9.5.
GetPaths(self, paths)¶Fills the array paths with the selected directories and filenames.
| Parameters: | paths (list of strings) – |
|---|
GetRootId(self)¶Returns the root id for the tree control.
| Return type: | wx.TreeItemId |
|---|
GetTreeCtrl(self)¶Returns a pointer to the tree control.
| Return type: | wx.TreeCtrl |
|---|
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 .
| Parameters: |
|
|---|
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) – |
|---|
SetDefaultPath(self, path)¶Sets the default path.
| Parameters: | path (string) – |
|---|
SetFilter(self, filter)¶Sets the filter string.
| Parameters: | filter (string) – |
|---|
SetFilterIndex(self, n)¶Sets the current filter index (zero-based).
| Parameters: | n (int) – |
|---|
SetPath(self, path)¶Sets the current path.
| Parameters: | path (string) – |
|---|
ShowHidden(self, show)¶| Parameters: | 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