fsleyes.controls.filetreepanel
¶
This module provides the FileTreePanel
class, which can be used
to browse the contents of structured directories which are described with
a filetree
.
See also the filetreemanager
module, which contains the logic for
generating the file list.
-
fsleyes.controls.filetreepanel.
BUILTIN_TREE_FILTER
= ['BedpostX', 'Diffusion', 'HCP_Surface', 'ProbtrackX', 'bet', 'dti', 'eddy', 'epi_reg', 'fast', 'topup', 'feat_reg', 'feat_stats']¶ Built-in
.tree
files with a name in this list are hidden from theFileTreePanel
interface. These trees are not very useful for our purposes of navigating multi-subject data directories.
-
class
fsleyes.controls.filetreepanel.
FileTreePanel
(parent, overlayList, displayCtx, frame)[source]¶ Bases:
fsleyes.controls.controlpanel.ControlPanel
The
FileTreePanel
can be used to browse the contents of structured directories which are described with afiletree
.The user needs to select a data directory, and a file tree. The file tree can be selected either from the drop down list of built-in trees, or a custom tree file can be selected.
Once the user has selected a file tree and a data directory, the
FileTypePanel
andVariablePanel
will be populated, allowing the user to choose which file types to display, and how to arrange them.When the user has selected some file types, the
FileListPanel
will display a grid containing all of the matching files that exist in the directory. The user can select a row to view the relevant files.The
FileTreeManager
handles the logic of working with theFileTree
and of displaying overlays.-
customTrees
= []¶ Whenever the user loads a custom tree file, its path is added to this list, so that the tree file dropdown box can be populated with previously loaded tree files.
-
__init__
(parent, overlayList, displayCtx, frame)[source]¶ Create a
FileTreePanel
.- Parameters
parent – The
wx
parent object.overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.frame – The
FSLeyesFrame
instance.
-
property
varPanel
¶ Return a reference to the
VariablePanel
.
-
property
fileTypePanel
¶ Return a reference to the
FileTypePanel
.
-
property
fileListPanel
¶ Return a reference to the
FileListPanel
.
-
property
treeChoice
¶ Return a reference to the file tree
wx.Choice
widget.
-
UpdateFileList
()[source]¶ Called by the sub-panels when the user changes any settings. Re-generates the file grid.
-
_loadTree
(treename, dirname)[source]¶ Called when a new tree or data directory is selected. Clears any previous file tree, and loads the new one. If either the tree or directory are
None
, any existing file tree is cleared.- Parameters
treename – File tree name or file
dirname – Data directory
-
_onLoadDir
(ev=None)[source]¶ Called when the user pushes the load data directory button.
Prompts the user to select a directory, then calls the
__loadTree()
method.
-
_onTreeChoice
(ev=None)[source]¶ Called when the user changes the built-in file tree selection. Calls the
__loadTree()
method.
-
_onCustomTree
(ev=None)[source]¶ Called when the user pushes the load custom tree button. Prompts the user to choose a file, then calls
__loadTree()
.
-
_onSave
(ev=None)[source]¶ Called when the save button is pushed. Prompts the user for a destination, and then saves the contents of the grid.
-
_onNotesChoice
(ev)[source]¶ Called when the user changes the notes column position choice. Calls
FileListPanel.NotesColumn()
accordingly.
-
__module__
= 'fsleyes.controls.filetreepanel'¶
-
-
class
fsleyes.controls.filetreepanel.
VariablePanel
(parent, ftpanel)[source]¶ Bases:
__main__.MockClass
The
VariablePanel
displays a list of available variables, allowing the user to choose between:Displaying each variable value on a different row (
<any>
, the default). These variables are referred to as varying.Displaying all variable value on the same row (
<all>
). These variables are referred to as fixed.Displaying one specific variable value. These are also included as varying variables.
-
__init__
(parent, ftpanel)[source]¶ Create a
VariablePanel
- Parameters
parent –
wx
parent objectftpanel – The
FileTreePanel
-
SetVariables
(vars)[source]¶ Set the variables to be displayed.
- Parameters
vars – Dict of
{ var : [value] }
mappings, containing all variables, and all of their possible values.
-
GetVaryings
()[source]¶ Return a dict of
{ var : val }
mappings containing all varying variables. The value for each variable may be one of:'*'
, indicating that all possible values for this variable should be consideredNone
, indicating that only instances where this variable is absent should be considered.A specific value, indicating that only this value should be considered.
-
_VariablePanel__onVariable
(ev)¶ Called when the user changes a variable setting. Calls the
FileTreePanel.Update()
method.
-
__module__
= 'fsleyes.controls.filetreepanel'¶
-
class
fsleyes.controls.filetreepanel.
FileListPanel
(parent, ftpanel, notes='right')[source]¶ Bases:
__main__.MockClass
The
FileListPanel
displays a grid of filetree variable values and file types, allowing the user to step through the files in the data directory.The user can drag varying variable columns to re-order them - this will trigger a call to
FileTreeManager.reorder()
.A Notes column contains text controls in each row, allowing the user to add notes. The position of this column can be set to either left or right of the fixed variable columns via the
NotesColumn()
method.-
__init__
(parent, ftpanel, notes='right')[source]¶ Create a
FileListPanel
.- Parameters
parent –
wx
parent objectftpanel – The
FileTreePanel
notes –
Location of the Notes column - one of:
'right'
- right-most column (default)'left'
- left-most column, after varying columns
The Notes column location can be changed later via the
NotesColumn()
method.
-
ResetGrid
(mgr)[source]¶ Clear and re-populate the file tree grid.
- Parameters
mgr – The
FileTreeManager
from which the variable and file information is retrieved.
-
NotesColumn
(notes)[source]¶ Set the position of the Notes column, either
'left'
or'right'
of the fixed variable columns.
-
_FileListPanel__createNotes
()¶ Called by
ResetGrid()
. Creates awx.TextCtrl
for each row, and adds it to the end column.
-
_FileListPanel__genColumnLabels
(varcols, fixedcols)¶ Called by
ResetGrid()
. Generates a label for each column in the grid, including the Notes column if it is visible.- Parameters
varcols – List of varying variable names
fixedcols – List of
(name, { var : val })
tuples, containing the file type and variable values of all fixed variable columns.
- Returns
A list of labels for each column
-
_FileListPanel__noteCharHook
(ev)¶ Called on character events for any of the note controls. If the character is a tab, up, or down arrow, focus is shifted to the next or previous note.
-
_FileListPanel__notesIndex
()¶ Returns the column index of the notes column. Assumes that a
FileTreeManager
has been passed toResetGrid()
.
-
_FileListPanel__onReorder
(ev)¶ Called when the user drags a column to change the column order. Calls the
FileTreeManager.reorder()
method, and updates the grid contents.
-
_FileListPanel__onSelect
(ev)¶ Called when the user selects a row. Calls the
FileTreeManager.Show()
method.
-
_FileListPanel__populateGrid
()¶ Populates the contents of the file tree grid. The contents are retrieved from the
FileTreeManager
.
-
__module__
= 'fsleyes.controls.filetreepanel'¶
-