Documentation
¶
Index ¶
- Variables
- func DirAndFileNoSlash(fpath string) string
- func FirstComment(sc string) string
- func IsTableFile(fname string) bool
- func NewDiffBrowserDirs(pathA, pathB string)
- func NewPlot(parent ...tree.Node) *plot.Plot
- func NewPlotFrom(from *plot.Plot, parent ...tree.Node) *plot.Plot
- func NewPlotWidget(parent ...tree.Node) (*plot.Plot, *plotcore.Plot)
- func NewTab[T any](tb Tabber, label string, mkfun func(tab *core.Frame) T) T
- func PromptOKCancel(ctx core.Widget, prompt string, fun func())
- func PromptString(ctx core.Widget, str string, prompt string, fun func(s string))
- func PromptStruct(ctx core.Widget, str any, prompt string, fun func())
- func TabAt[T any](tb Tabber, label string) T
- func TensorFS(fn *filetree.Node) *tensorfs.Node
- func TrimOrderPrefix(s string) string
- type Basic
- type Browser
- func (br *Browser) MakeScriptsToolbar(p *tree.Plan)
- func (br *Browser) MakeToolbar(p *tree.Plan)
- func (t *Browser) SetDataRoot(v string) *Browser
- func (t *Browser) SetFS(v fs.FS) *Browser
- func (t *Browser) SetFiles(v *DataTree) *Browser
- func (t *Browser) SetScriptsDir(v string) *Browser
- func (t *Browser) SetSplits(v *core.Splits) *Browser
- func (t *Browser) SetStartDir(v string) *Browser
- func (t *Browser) SetTabs(v *Tabs) *Browser
- func (t *Browser) SetToolbar(v *core.Toolbar) *Browser
- func (br *Browser) UpdateFiles()
- func (br *Browser) UpdateScripts()
- type DataTree
- type FileNode
- func (fn *FileNode) ContextMenu(m *core.Scene)
- func (fn *FileNode) DiffDirs()
- func (fn *FileNode) EditFile()
- func (fn *FileNode) EditFiles()
- func (fn *FileNode) GetFileInfo() error
- func (fn *FileNode) GridFile()
- func (fn *FileNode) GridFiles()
- func (fn *FileNode) Init()
- func (fn *FileNode) OpenFile() error
- func (fn *FileNode) PlotFile()
- func (fn *FileNode) PlotFiles()
- func (fn *FileNode) Tabber() Tabber
- func (fn *FileNode) WidgetTooltip(pos image.Point) (string, image.Point)
- type Tabber
- type Tabs
- func (ts *Tabs) AsLab() *Tabs
- func (ts *Tabs) EditorFile(label, filename string) *textcore.Editor
- func (ts *Tabs) EditorString(label, content string) *textcore.Editor
- func (ts *Tabs) GoUpdatePlot(label string) *plotcore.Editor
- func (ts *Tabs) GridTensorFS(dfs *tensorfs.Node) *tensorcore.TensorGrid
- func (ts *Tabs) Init()
- func (ts *Tabs) NewPlot(label string) *plotcore.Editor
- func (ts *Tabs) Plot(label string, plt *plot.Plot) *plotcore.Plot
- func (ts *Tabs) PlotTable(label string, dt *table.Table) *plotcore.Editor
- func (ts *Tabs) PlotTensorFS(dfs *tensorfs.Node) *plotcore.Editor
- func (ts *Tabs) SliceTable(label string, slc any) *core.Table
- func (ts *Tabs) TabUpdateRender(label string) core.Widget
- func (ts *Tabs) TensorEditor(label string, tsr tensor.Tensor) *tensorcore.TensorEditor
- func (ts *Tabs) TensorGrid(label string, tsr tensor.Tensor) *tensorcore.TensorGrid
- func (ts *Tabs) TensorTable(label string, dt *table.Table) *tensorcore.Table
- func (ts *Tabs) UpdatePlot(label string) *plotcore.Editor
- type Treer
Constants ¶
This section is empty.
Variables ¶
var ( // LabBrowser is the current Lab Browser, for yaegi / Go consistent access. LabBrowser *Browser // RunScript is set if labscripts is imported. // Runs given script name on browser's interpreter. RunScript func(br *Browser, scriptName string) error // RunScriptCode is set if labscripts is imported. // Runs given code on browser's interpreter. RunScriptCode func(br *Browser, code string) error )
Functions ¶
func DirAndFileNoSlash ¶ added in v0.1.1
DirAndFileNoSlash returns fsx.DirAndFile with slashes replaced with spaces. Slashes are also used in core Widget paths, so spaces are safer.
func FirstComment ¶
FirstComment returns the first comment lines from given .goal file, which is used to set the tooltip for scripts.
func IsTableFile ¶
func NewDiffBrowserDirs ¶
func NewDiffBrowserDirs(pathA, pathB string)
NewDiffBrowserDirs returns a new diff browser for files that differ within the two given directories. Excludes Job and .tsv data files.
func NewPlot ¶
NewPlot is a simple helper function that does plot.New and plotcore.NewPlot, only returning the plot.Plot for convenient use in lab plots. See NewPlotWidget for a version that also returns the plotcore.Plot. See also NewPlotFrom.
func NewPlotFrom ¶
NewPlotFrom is a version of NewPlot that copies plot data from the given starting plot.
func NewPlotWidget ¶
NewPlotWidget is a simple helper function that does plot.New and plotcore.NewPlot, returning both the plot.Plot and plotcore.Plot for convenient use in lab plots. See NewPlot for a version that only returns the more commonly useful plot.Plot.
func NewTab ¶
NewTab recycles a tab with given label, or returns the existing one with given type of widget within it. The existing that is returned is the last one in the frame, allowing for there to be a toolbar at the top. mkfun function is called to create and configure a new widget if not already existing.
func PromptOKCancel ¶
PromptOKCancel prompts the user for whether to do something, calling the given function if the user clicks OK.
func PromptString ¶
PromptString prompts the user for a string value (initial value given), calling the given function if the user clicks OK.
func PromptStruct ¶
PromptStruct prompts the user for the values in given struct (pass a pointer), calling the given function if the user clicks OK.
func TensorFS ¶
TensorFS returns the tensorfs representation of this item. returns nil if not a dataFS item.
func TrimOrderPrefix ¶
TrimOrderPrefix trims any optional #- prefix from given string, used for ordering items by name.
Types ¶
type Basic ¶
Basic is a basic data browser with the files as the left panel, and the Tabber as the right panel.
func NewBasic ¶
NewBasic returns a new Basic with the given optional parent: Basic is a basic data browser with the files as the left panel, and the Tabber as the right panel.
func NewBasicWindow ¶
NewBasicWindow returns a new Lab Browser window for given file system (nil for os files) and data directory. do RunWindow on resulting core.Body to open the window.
type Browser ¶
type Browser struct {
// FS is the filesystem, if browsing an FS.
FS fs.FS
// DataRoot is the path to the root of the data to browse.
DataRoot string
// StartDir is the starting directory, where the app was originally started.
StartDir string
// ScriptsDir is the directory containing scripts for toolbar actions.
// It defaults to DataRoot/dbscripts
ScriptsDir string
// Scripts are interpreted goal scripts (via yaegi) to automate
// routine tasks.
Scripts map[string]string `set:"-"`
// Interpreter is the interpreter to use for running Browser scripts.
// is of type: *goal/interpreter.Interpreter but can't use that directly
// to avoid importing goal unless needed. Import [labscripts] if needed.
Interpreter any `set:"-"`
// Files is the [DataTree] tree browser of the tensorfs or files.
Files *DataTree
// Tabs is the [Tabs] element managing tabs of data views.
Tabs *Tabs
// Toolbar is the top-level toolbar for the browser, if used.
Toolbar *core.Toolbar
// Splits is the overall [core.Splits] for the browser.
Splits *core.Splits
}
Browser holds all the elements of a data browser, for browsing data either on an OS filesystem or as a tensorfs virtual data filesystem. It supports the automatic loading of [goal] scripts as toolbar actions to perform pre-programmed tasks on the data, to create app-like functionality. Scripts are ordered alphabetically and any leading #- prefix is automatically removed from the label, so you can use numbers to specify a custom order. It is not a core.Widget itself, and is intended to be incorporated into a core.Frame widget, potentially along with other custom elements. See Basic for a basic implementation.
func (*Browser) MakeScriptsToolbar ¶
MakeScriptsToolbar is a maker for adding buttons for each uppercase script to the toolbar.
func (*Browser) MakeToolbar ¶
MakeToolbar makes a default toolbar for the browser, with update files and update scripts buttons, followed by MakeScriptsToolbar for the scripts.
func (*Browser) SetDataRoot ¶
SetDataRoot sets the [Browser.DataRoot]: DataRoot is the path to the root of the data to browse.
func (*Browser) SetFiles ¶
SetFiles sets the [Browser.Files]: Files is the DataTree tree browser of the tensorfs or files.
func (*Browser) SetScriptsDir ¶
SetScriptsDir sets the [Browser.ScriptsDir]: ScriptsDir is the directory containing scripts for toolbar actions. It defaults to DataRoot/dbscripts
func (*Browser) SetSplits ¶
SetSplits sets the [Browser.Splits]: Splits is the overall core.Splits for the browser.
func (*Browser) SetStartDir ¶
SetStartDir sets the [Browser.StartDir]: StartDir is the starting directory, where the app was originally started.
func (*Browser) SetTabs ¶
SetTabs sets the [Browser.Tabs]: Tabs is the Tabs element managing tabs of data views.
func (*Browser) SetToolbar ¶
SetToolbar sets the [Browser.Toolbar]: Toolbar is the top-level toolbar for the browser, if used.
func (*Browser) UpdateScripts ¶
func (br *Browser) UpdateScripts()
UpdateScripts updates the Scripts and updates the toolbar.
type DataTree ¶
DataTree is the databrowser version of filetree.Tree, which provides the Tabber to show data editors.
func AsDataTree ¶
AsDataTree returns the given value as a DataTree if it has an AsDataTree() method, or nil otherwise.
func NewDataTree ¶
NewDataTree returns a new DataTree with the given optional parent: DataTree is the databrowser version of filetree.Tree, which provides the Tabber to show data editors.
func (*DataTree) AsDataTree ¶
type FileNode ¶
FileNode is databrowser version of FileNode for FileTree
func NewFileNode ¶
NewFileNode returns a new FileNode with the given optional parent: FileNode is databrowser version of FileNode for FileTree
func (*FileNode) ContextMenu ¶
func (*FileNode) DiffDirs ¶
func (fn *FileNode) DiffDirs()
DiffDirs displays a browser with differences between two selected directories
func (*FileNode) EditFile ¶
func (fn *FileNode) EditFile()
EditFile pulls up this file in a texteditor
func (*FileNode) EditFiles ¶
func (fn *FileNode) EditFiles()
EditFiles calls EditFile on selected files
func (*FileNode) GetFileInfo ¶
func (*FileNode) GridFiles ¶
func (fn *FileNode) GridFiles()
GridFiles calls GridFile on selected files
func (*FileNode) PlotFiles ¶
func (fn *FileNode) PlotFiles()
PlotFiles calls PlotFile on selected files
type Tabber ¶
type Tabber interface {
core.Tabber
// AsLab returns the [lab.Tabs] widget with all the tabs methods.
AsLab() *Tabs
}
Tabber is a core.Tabs based widget that has support for opening tabs for plotcore.Editor and tensorcore.Table editors, among others.
type Tabs ¶
Tabs implements the Tabber interface.
var Lab *Tabs
Lab is the current Tabs, for yaegi / Go consistent access.
func NewTabs ¶
NewTabs returns a new Tabs with the given optional parent: Tabs implements the Tabber interface.
func (*Tabs) EditorFile ¶
EditorFile opens an editor tab for given file.
func (*Tabs) EditorString ¶
EditorString recycles a textcore.Editor tab, displaying given string.
func (*Tabs) GoUpdatePlot ¶
GoUpdatePlot calls GoUpdatePlot on plot at tab with given name. Does nothing if tab name doesn't exist (returns nil).
func (*Tabs) GridTensorFS ¶
func (ts *Tabs) GridTensorFS(dfs *tensorfs.Node) *tensorcore.TensorGrid
GridTensorFS recycles a tab with a Grid of given tensorfs.Node.
func (*Tabs) PlotTensorFS ¶
PlotTensorFS recycles a tab with a Plot of given tensorfs.Node.
func (*Tabs) SliceTable ¶
SliceTable recycles a tab with a core.Table widget to view the given slice of structs.
func (*Tabs) TabUpdateRender ¶ added in v0.1.3
TabUpdateRender calls UpdateRender on content of given tab. This is the best way to update display widgets during running an ongoing computation.
func (*Tabs) TensorEditor ¶
func (ts *Tabs) TensorEditor(label string, tsr tensor.Tensor) *tensorcore.TensorEditor
TensorEditor recycles a tab with a tensorcore.TensorEditor widget to view given Tensor.
func (*Tabs) TensorGrid ¶
func (ts *Tabs) TensorGrid(label string, tsr tensor.Tensor) *tensorcore.TensorGrid
TensorGrid recycles a tab with a tensorcore.TensorGrid widget to view given Tensor.
func (*Tabs) TensorTable ¶
TensorTable recycles a tab with a tensorcore.Table widget to view given table.Table, using its own table.Table as tv.Table. Use tv.Table.Table to get the underlying *table.Table Use tv.Table.Sequential to update the Indexed to view all of the rows when done updating the Table, and then call br.Update()