Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SingleTreeSelect

The single-pane folder browser: one folder on show at a time, with .. to walk up.

with sc.Popover('Browse', panel_align='row', panel_max_height=500):
    tree = sc.SingleTreeSelect(filter='.txt')

path = tree.value.get()

Layout:

[ /current/folder v ] [home] [refresh] [bucket] [mode]   <- toolbar
..   (go to parent)
subfolder/                                        ->
another-file.txt
[                    Confirm                    ]

Arguments

ArgumentTypeMeaning
labelstr | PropertyLabel above the panel
start_directorystrFolder to open, default the cwd
home_directorystrWhere home returns; defaults to start_directory
filterstr or tupleSuffixes to keep
heightintCap the listing height and scroll
widthsize keywordPanel width
selection_modestr or tuple'single', 'multiple', 'multicross', 'none'
initial_modestrWhich offered mode opens
show_confirm_buttonboolDefault True
borderboolDraw a frame; defaults to standalone
label_visibilitystrSee Inputs
helpstr | PropertyTooltip

leading and trailing are builders run at the head and tail of the toolbar row. They are used by wrappers to put their own widgets around the actions, not usually by an app.

Properties

  • value: the selection.
    • 'single': one path, or ''.
    • Multi modes: a list of paths.
  • mode: the active mode.
  • directory: the folder on show (read-only).
  • rows_visible: whether the listing is drawn.

Prefer select() and clear() over writing value directly; those keep the listing in step.

Signals

  • value.on_change: the selection changed.
  • on_navigate(directory): the listing moved to a new folder.
  • on_submit(paths): Confirm was clicked; carries the resolved paths.

Methods

  • reload(): re-read the current folder from disk.
  • select(path): add a path that is not in the listing.
  • clear(): drop the selection.
  • resolve(): the paths Confirm reports.
  • open_path(path): move the panel onto what a path names.

Widgets

tree.widgets exposes two sub-components:

  • bottom_bar: the Row under the listing. Enter it to append actions after the Confirm button.
  • confirm_button: the button itself, reachable even when hidden.
with tree.widgets['bottom_bar']:
    sc.Button('Open input folder')

Selection modes

  • 'single' picks one node.
  • 'multiple' holds picks within the folder being browsed. Walking away drops them.
  • 'multicross' gathers picks into a bucket across folders. Only a mode set containing it draws the bucket.
  • 'none' draws no boxes; the rows are read-only.

A tuple draws a mode switch, but only when it contains more than one mode.