All Files in undroid/tsb/
Not logged in

Files in directory undroid/tsb in any check-in

  • asciimath
  • echarts
  • examples
  • README.md
  • taygete_logo.png
  • tsb.tcl

Taygete Scrap Book (WIP)

This is an experimental, partial, compact rebuild of some ideas of Jupyter Notebook which first was presented at EuroTcl 2019. The name is derived from the small retrograde irregular satellite of Jupiter called Taygete, aka Jupiter XX.

It consists of a webview (the rendering component/library of a web browser) with an added Tcl interface, plus some Tcl and JavaScript to provide a user interface resembling Jupyter Notebook. The webview part is basically taken from the Tiny cross-platform webview library for C/C++/Golang with the Python interface used as starting point for the Tcl interface.

No browser and webserver are required so it can be made into one binary with zero installation and without requiring network infrastructure. Uncloudy, so to speak clean hot air.

A ready made ZIP kit for immediate experimentation is available in tsbkit. It supports the three major desktop platforms Windows (32 and 64 bit), MacOS (Intel, 64 bit), Linux (Intel, 32 and 64 bit, distro agnostic but a decent version with Gnome 3 runtime is required). If started without further arguments, it presents an overview page with links to examples.

How does it work?

In Tcl a webview is created

set W [twv::new -width 800 -height 600 -url ... -callback ...]

From Tcl, JavaScript code can be evaluated using

$W eval JavaScript-code-string
$W call JavaScript-function ?string-argument...?

From JavaScript, Tcl code can be evaluated using

window.external.invoke(Tcl-callback-argument);

The bootstrap in the webview constructor is an URL which contains JavaScript to evaluate Tcl code, which writes the skeleton of a HTML document including the necessary JavaScript functions to interface with the rest of the Tcl code, i.e. calls

document.write(HTML+CSS+JavaScript-code);
document.close();

With these means a REPL is build which initially consists of an HTML textarea as input field plus two HTML divs for output of preformatted text and HTML. When text is input into the textarea and <Shift-Return> is entered, that text is evaluated as Tcl script, or HTML/Markdown. The result is put into one of the HTML divs for output. In case the evaluation did not produce an error, a new empty HTML textarea plus two new HTML divs for output are added to the document, which then are used for the next evaluation, and so on.

And what is it good for?

Good question. At least, one can quickly, interactively check out Tcl code and at the same time write some good looking documentation, which can be immediately printed out (platform dependent) or written as HTML to a file for later display in a browser.

How to hang yourself without a rope?

The current version does not use a Tcl slave interpreter for command evaluation (which would allow for limitation of runtime and a "safe" set of available Tcl commands). Thus, the easiest way to hang yourself is to enter

while {1} {}

No measures are implemented to limit the interpreter's capabilities, thus malicious creativity like

exec sudo sh -c {rm -rf .*}

is possible. You have been warned!