Check-in [a817a75a56]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:improve twv examples
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a817a75a5656d1d55e30970aab0e12807fca13bb
User & Date: chw 2019-06-21 04:55:56
Context
2019-06-21
05:00
add selected tk upstream changes check-in: b18936dce6 user: chw tags: trunk
04:55
improve twv examples check-in: a817a75a56 user: chw tags: trunk
2019-06-20
06:01
cleanup some build scripts for twv install check-in: 3712d60f4e user: chw tags: trunk
Changes

undroid/tkdnd/demos/dndSpy.tcl became a regular file.

Changes to undroid/tsb/examples/northwind.tsb.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    catch {$handle perform} code
    if {$code != 0} {
        return -code error [curl::easystrerror $code]
    }
    $handle cleanup
    return $result
}} 4 {#HTML
<p>The Northwind Sample data is on github, here's the base URL</p>} 5 {set BASEURL https://raw.githubusercontent.com/jpwhite3/northwind-SQLite3/master} 6 {#HTML
<p>Let's retrieve the schema diagram of the Northwind database ...</p>} 7 {img_from_binary [curl_get ${BASEURL}/Northwind_ERD.png] image/png 0} 8 {#HTML
<p>Now we create an in-memory SQLite3 database,
fill it with the NorthWind data from SQL source,
and finally list data from the [Categories] table.</p>} 9 package\ require\ sqlite3\n\nsqlite3\ DB\ :memory:\n\nDB\ eval\ \[encoding\ convertfrom\ iso8859-15\ \\\n\ \ \ \ \[curl_get\ \$\{BASEURL\}/Northwind.Sqlite3.create.sql\]\]\n\ntable\ \{CategoryID\ CategoryName\ Description\}\ \\\n\ \ \ \ \[DB\ eval\ \{select\ CategoryID,\ CategoryName,\ Description\ from\ \[Categories\]\}\] 10 {#HTML
<p>Display the images from table [Categories].</p>} 11 {foreach img [DB eval {select Picture from [Categories]}] {
    img_from_binary $img image/jpeg 0
}} 12 {tsb::save northwind.tsb}







|



|



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    catch {$handle perform} code
    if {$code != 0} {
        return -code error [curl::easystrerror $code]
    }
    $handle cleanup
    return $result
}} 4 {#HTML
<p>The Northwind Sample data is on github, here's the base URL</p>} 5 set\ BASEURL\ \\\n\ \ \ \ https://raw.githubusercontent.com/jpwhite3/northwind-SQLite3/master 6 {#HTML
<p>Let's retrieve the schema diagram of the Northwind database ...</p>} 7 {img_from_binary [curl_get ${BASEURL}/Northwind_ERD.png] image/png 0} 8 {#HTML
<p>Now we create an in-memory SQLite3 database,
fill it with the NorthWind data from SQL source,
and finally list data from the [Categories] table.</p>} 9 package\ require\ sqlite3\n\nsqlite3\ DB\ :memory:\n\nDB\ eval\ \[encoding\ convertfrom\ iso8859-15\ \\\n\ \ \ \ \[curl_get\ \$\{BASEURL\}/Northwind.Sqlite3.create.sql\]\]\n\ntable\ \{CategoryID\ CategoryName\ Description\}\ \[DB\ eval\ \{\n\ \ \ \ select\ CategoryID,\ CategoryName,\ Description\ from\ \[Categories\]\n\}\] 10 {#HTML
<p>Display the images from table [Categories].</p>} 11 {foreach img [DB eval {select Picture from [Categories]}] {
    img_from_binary $img image/jpeg 0
}} 12 {tsb::save northwind.tsb}

Changes to undroid/tsb/tsb.tcl.

438
439
440
441
442
443
444









445
446
447
448
449
450
451
452



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
...
795
796
797
798
799
800
801

802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824









825
826
827
828









829
830
831
832
833
834
835
...
844
845
846
847
848
849
850

851
852
853
854
855
856
857
858
...
989
990
991
992
993
994
995

996
997
998
999
1000
1001
1002
1003
    if {$name eq ""} {
	set selname 1
	set name [$::W dialog open "Write HTML To File"]
    }
    if {$name eq ""} {
	return
    }









    set t $title
    if {$file ne ""} {
	append t " - [file tail $file]"
    }
    set t [htmlquote $t]
    set f [open $name w]
    puts $f $D_head
    puts $f "<title>$t</title>"



    puts $f $D_style
    puts $f "</head><body>\n"
    puts $f [::tsb::dump]
    puts $f "</body></html>"
    close $f
    if {$selname} {
	set cmd [dict get [info frame -1] cmd]
	set newcmd $cmd
	lappend newcmd $name
	::tsb::change_field $cmd $newcmd
    }
    return -code 4 ;# continue
}

# A minimal canvas emulation for plotchart. The svg method
# produces SVG into the current (output) field.
#
#  set C [::tsb::canvas ...]
................................................................................
    set D_head {<!DOCTYPE html><html lang="en"><head>}
    append D_head {<meta charset="utf-8">}

    # STYLE, CSS
    set D_style {
	<style>
	body {

	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, Monaco, monospace;
	    font-size: 100%;
	}
	label {
	    font-family: Consolas, Monaco, monospace;
	    margin: 1px;
	    padding: 1px;
	}
	pre {
	    /* overflow-x: auto; */
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, Monaco, monospace;
	    font-size: 100%;









	}
	.infield * {
	    vertical-align: middle;
	}









	.tin {
	    width: 85%;
	    resize: none;
	    overflow: auto;
	}
	.tin, .tin:disabled {
	    border: 1px solid #AAAAAA;
................................................................................
	    margin: 2px;
	    padding: 4px;
	}
	.tbl {
	    border: 1px solid;
	    border-collapse: collapse;
	    margin-left: 1em;

	    width: 90%;
	}
	.tbl th {
	    border: 1px solid;
	    border-collapse: collapse;
	}
	.tbl td {
	    border: 1px solid;
................................................................................
	};

	var Field = function(id) {
	    var div = document.createElement('div');
	    div.className = 'field';
	    var html = '\n <a href="#in' + id + '"></a>';
	    html += '\n <div class="infield" id="in' + id + '">';

	    html += '\n  <label for="code' + id + '">in(' + id + ')</label>';
	    html += '\n  <textarea class="tin" id="code' + id + '" rows="1"';
	    html += '></textarea>\n </div>';
	    html += '\n <a href="#out' + id + '"></a>';
	    html += '\n <div id="out' + id + '-pre">';
	    html += '<pre></pre></div>';
	    html += '\n <div id="out' + id + '-raw"></div>\n';
	    div.innerHTML = html;







>
>
>
>
>
>
>
>
>








>
>
>
|




<
<
<
<
<
<







 







>




|
|
<
<
<
<
<










|
|
>
>
>
>
>
>
>
>
>




>
>
>
>
>
>
>
>
>







 







>
|







 







>
|







438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469






470
471
472
473
474
475
476
...
801
802
803
804
805
806
807
808
809
810
811
812
813
814





815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
...
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
....
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
    if {$name eq ""} {
	set selname 1
	set name [$::W dialog open "Write HTML To File"]
    }
    if {$name eq ""} {
	return
    }
    if {$selname} {
	set cmd [dict get [info frame -1] cmd]
	set newcmd $cmd
	lappend newcmd $name
	::tsb::change_field $cmd $newcmd
    }
    if {[info exists ::ID]} {
	$::W call Wclear $::ID
    }
    set t $title
    if {$file ne ""} {
	append t " - [file tail $file]"
    }
    set t [htmlquote $t]
    set f [open $name w]
    puts $f $D_head
    puts $f "<title>$t</title>"
    # No hover in output
    set style $D_style
    regsub -all -- :hover $style :nohover style
    puts $f $style
    puts $f "</head><body>\n"
    puts $f [::tsb::dump]
    puts $f "</body></html>"
    close $f






    return -code 4 ;# continue
}

# A minimal canvas emulation for plotchart. The svg method
# produces SVG into the current (output) field.
#
#  set C [::tsb::canvas ...]
................................................................................
    set D_head {<!DOCTYPE html><html lang="en"><head>}
    append D_head {<meta charset="utf-8">}

    # STYLE, CSS
    set D_style {
	<style>
	body {
	    margin: 1em 2em 1em 2em;
	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, Roboto Mono, Liberation Mono, monospace;
	    font-size: 90%;





	}
	pre {
	    /* overflow-x: auto; */
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, Roboto Mono, Liberation Mono, monospace;
	    font-size: 90%;
	}
	img {
	    max-width: 95%;
	}
	.field {
	    border: 1px solid transparent;
	}
	.field:hover {
	    border: 1px dotted #AAAAAA;
	}
	.infield * {
	    vertical-align: middle;
	}
	.tlabel {
	    font-family: Consolas, Roboto Mono, Liberation Mono, monospace;
	    font-size: 90%;
	    margin: 1px;
	    padding: 1px;
	    width: 7ex;
	    display: inline-block;
	    text-align: right;
	}
	.tin {
	    width: 85%;
	    resize: none;
	    overflow: auto;
	}
	.tin, .tin:disabled {
	    border: 1px solid #AAAAAA;
................................................................................
	    margin: 2px;
	    padding: 4px;
	}
	.tbl {
	    border: 1px solid;
	    border-collapse: collapse;
	    margin-left: 1em;
	    margin-right: 1em;
	    max-width: 100%;
	}
	.tbl th {
	    border: 1px solid;
	    border-collapse: collapse;
	}
	.tbl td {
	    border: 1px solid;
................................................................................
	};

	var Field = function(id) {
	    var div = document.createElement('div');
	    div.className = 'field';
	    var html = '\n <a href="#in' + id + '"></a>';
	    html += '\n <div class="infield" id="in' + id + '">';
	    html += '\n  <label class="tlabel"';
	    html += ' for="code' + id + '">in(' + id + ')</label>';
	    html += '\n  <textarea class="tin" id="code' + id + '" rows="1"';
	    html += '></textarea>\n </div>';
	    html += '\n <a href="#out' + id + '"></a>';
	    html += '\n <div id="out' + id + '-pre">';
	    html += '<pre></pre></div>';
	    html += '\n <div id="out' + id + '-raw"></div>\n';
	    div.innerHTML = html;