by [Theo Verelst] The [Bwise] tcl/tk package is a way back compatible package for making graphs of blocks which can be executed as chains with tcl code. See the currently latest version here: [Bwise version 0.34, all in one file, 8.4 compatible] I did a presentation on [FOSDEM 2004] open source conference, where I (in a short time) had prepared a presentation interface for, to make bwise work with an overhead projector setup to display text, while remaining functional for demo-ing live with blocks. [http://82.171.148.176/Wiki/pres1.jpg] The code to make this possible is as follows (assuming you've already loaded Bwise, and that the text below, without leading spaces, is put in '''bwisepres.txt'''): ---- set cb [pwd] # so we can cd $cb later cd {c:/Theo/Tcl} # you'll have other paths # puts {C:/cygwin/home/Theo/Tcl} # small reminder printed at start open_text {bwisepres.txt} # assuming that file is in current dir, wm iconify .tt # F1 reloads text, F2 = Next, F3 = Prev bind . {if ![info exists prescount] {set prescount 0} ; presp dis} bind . {presp next} bind . {presp prev} append env(PATH) ";c:\\cygwin\\bin" # I wanted to be able to use cygwin for the C image example proc presp { {c} } { global prescount; set t $prescount; switch $c "next" { set prescount [expr [lindex [split [.tt.t search -- ---- $prescount.0] .] 0]+1] } "prev" { set prescount [expr [lindex [split [.tt.t search -back -- ---- [expr $prescount-3].end] .] 0]+1] } "dis" { } set t [expr [lindex [split [.tt.t search -- ---- $prescount.0] .] 0]+1] set o {} ; set i 0 foreach l [split [.tt.t get $prescount.0 [expr $t-2].end] \n] { if {$i < 1} { lappend o {-fill blue} $l } { lappend o {} $l } incr i } welcome $o } proc welcome { {we {}} } { global mc $mc del welcome bind $mc {global mc; $mc del welcome; bind $mc {}} if {$we == ""} {set we { {-fill blue} " Welcome to Bwise version 0.34" {} {} {-fill red} "Press left mouse button once in this canvas to delete welcome message!" {} "This canvas can be clicked on to create blocks with the" {} "rigth or middle mouse button menu, see top of source code." {} "" {} "The paper image button creates a tcl shell." {} "Connect blocks by clicking on two pins and press wire." {} "Double click blocks to select them for \\\"delete\\\" button." {} "Saving the canvas doesn't save block entry components (yet)." {} "Right-click block yellow part to get block menu." {} "Use Funprop on first block of a network to 'run' it" } } set i 0; foreach {a t} $we { eval $mc create text 15 [expr 20+30*$i] -font \"helvetica 14\" -anchor nw -tag welcome $a -text \"$t\" incr i } } ---- Apart from this, we need the actual texts to be displayed, which are stored in this format, here including the whole presentation (called bwisepres.txt): ---- ---- Welcome to BWise by Theo Verelst - Blockwise programming - Net based flow execution - Tk canvas graphical nets - Utilities ---- Main idea and history Prototyping all over In e.g. EE blocks and diagrams are normal programming by units is good practice various specific uses in mind, which are working many limitations, unfinished ideas, and some anomalities ---- Creating a block Rationale: if you can't block it, you're definitions are probably weak functional analysis new-block functions and popup menu Left pins inputs, Right pins outputs ---- Block example a simple pass-through block standard block facilities newproc {} example_block ---- Block data Right-click popup menu Data Window List of block variables Editable entries Mind braces around variable names with dots ---- Block Evaluate Either from menu or button on data window Evaluates tcl from variable block.bfunc at toplevel #0 ---- Connecting Blocks Click on pins to select, press Wire. Connections follow displaced blocks Each connection has unique name connect wirename block1 pin1 block2 pin2 ---- Transfering Data transfer menu transfers data on output pins to all connected pins Visual feedback (slowed down for demo) ---- Automatic chain block eval and transfer 'flooding' based algorithms net_funprop: minimal # evals/transfers algorithm latter introduces an invisible state to the net ---- TK Canvas Use Block elements share first tag name Main yellow rectangle has 'block' as third tag much use of canvas tags some library functions like tag_and (older tk) ---- Block select and delete double click on main square creates red selection Del Sel button deletes all selected blocks and their wires. ---- Procedure Window List of all main namespace procs double click a proc to edit it initial procs and names with tk_* and tcl_* are filtered ---- Proc Edit Text widget which is filled with actual body window is eval-ed at buttonpress to redef change proc name to create a new, and refresh single button saving of changed procs ---- Forming commands with a proc double click proc put cursor in pro_args line click arguments with non-default value and fill in Form Command and Execute ---- Creating Blocks from Functions Ideally a unambinguous, straightforward step works best for functions with * all-formal ingoing info (no globals or uplevel) * only return value as outcoming info ---- Procedure to block choose proc, and press button block appears at fixed point all arguments and return value are pins defaults are filled in (pin vars) ---- net_ functions various net-related lib procs for instance net_left netlistout generates list of {bl p bl2 p2} gen_netlist generates eval-able connect list ---- Predefined Block generators See right popupmenu Entry and Mon text windows array for testing purposes Stack, Term, Seq ---- Image blocks newimage birds.gif newimage bridge.jpg ---- Example: C compiled image processing Uses (free) cygwin C compiler from BWise compiler, Image-generator and viewer blocks Useful real time net programs ---- ---- Don't forget to remove the leading space from here, or adapt the code a bit. Now BWise can be used as normal, any left mouse click on the canvas removes the text, but leaves the rest in place, and the text can be redrawn by pressing F1. F2 procedes to the next text field, F3 back to the previous. The text file can be arbitrary in format and lenght, the first line of a block is presented in blue. The 'open_text' command has made a window with text widget, which can run-time be edited, for instance to prepare a demonstration, it can be edited interleaved with viewing without problem. Save and load work instantaneously on the file with name provided in the entry, that is NO CONFIRMATION IS ASKED FOR to load and save files !! ---- !!!!!! %| [Category Application] | [Category Bwise] |% !!!!!!