by Theo Verelst
The Bwise package can save items on a (the main bwise) canvas to a tcl/tk source-able file, but thus far only graphical items, no widgets.
This upgrade proc saves the Entry and Mon blocks, too. More will follow, this is not heavily tested. In fact I just found out that -bg -fg and -bd cases aren't filtered out yet, they need to be treated as special cases since reading back the conf values in a command generates an error ! (I'll update soon)
The above blocks are all saved, the red marked bottom ones aren't
For those interested, simply start bwise, and load this procedure to replace the old one.
proc save_canvas { } {
global mc set o "" set sv {bcount scopeindex wireindex shellindex drumindex entrycount moncount proccount seqcount stackcount termindex textcount} eval global $sv eval {append o global " " $sv \n} foreach i $sv { catch { eval set j $$i ; append o set " " $i " " $j \n } } # save images on canvas foreach in [image names] { if {[$in cget -file] != ""} { append o "image create photo " $in " -file " [$in cget -file] \n } } # save all canvas items except menus and (for now) sub-windows foreach i [$mc find all] { if {[$mc type $i] != "window" && [$mc type $i] != "menu"} { append o $mc " " create " " [$mc type $i] " " [$mc coords $i] foreach k [ $mc itemco $i] { append o " " [lindex $k 0] " " [list [lindex $k end]] } append o \n } } # save all widgets under the Bwise canvas, with all reloadable options set oo {}; foreach w [ilist $mc] { if {[winfo class $w] != "Menu"} { set p {}; foreach i [$w conf] { # filter out options of which the value starts with - if {[string index [lindex $i end] 0] != "-"} { lappend p [list [lindex $i 0] [lindex $i end]] } }; append o "[string tolower [winfo class $w]] $w " ; foreach i $p {append o $i " "} ; append o "\n" } } # save all canvas window items, which match tops of sub widget hierarchies foreach i [$mc find all] { if {[$mc type $i] == "window" } { append o $mc " " create " " [$mc type $i] " " [$mc coords $i] foreach k [ $mc itemco $i] { append o " " [lindex $k 0] " " [list [lindex $k end]] } append o \n } } uplevel #0 { set ooo {} foreach bi [tag_and {block}] { set b [block_name_fromid $bi] foreach i [lsort -dict [info vars $b.*]] { if {[string index $i 0] != "\$" && [array exists $i] == 0} { eval set ttt $\{$i\} #set uuu "set \{$i\} \{$ttt\} \n" #eval set uuu $\{$i\} append ooo "set " $i " " \{ $ttt \} \n } } } } global ooo set fn [tk_getSaveFile]; if {$fn != ""} { set fd [open $fn w]; puts $fd $o; puts $fd {# now the block related variables\n} puts $fd $ooo; close $fd }
}