Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update the build for taotk-form.tcl |
---|---|
Timelines: | family | ancestors | descendants | both | fsar |
Files: | files | file ages | folders |
SHA1: |
9e680e2748dade84b3af5eefca8418b4 |
User & Date: | hypnotoad 2018-11-30 21:42:02.441 |
Context
2018-12-05
| ||
15:23 | Adding a snapshot of every tcllib module tool and tao depend on check-in: 06416af04b user: hypnotoad tags: fsar | |
2018-11-30
| ||
21:42 | Update the build for taotk-form.tcl check-in: 9e680e2748 user: hypnotoad tags: fsar | |
2018-11-01
| ||
22:09 | Typo fix check-in: 2b6b0200fe user: hypnotoad tags: fsar | |
Changes
Changes to modules/taotk-form/taotk-form.tcl.
︙ | ︙ | |||
376 377 378 379 380 381 382 | ### ### # Object which is the vessel for many other objects # particularly dynamic widgets ### tool::define ::taotk::meta::form { superclass ::tool::ui::form ::taotk::meta::megawidget | | | | | | | | | < < < < < < < | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | ### ### # Object which is the vessel for many other objects # particularly dynamic widgets ### tool::define ::taotk::meta::form { superclass ::tool::ui::form ::taotk::meta::megawidget method form::default {f field args} { set p $f.$field if {[winfo exists $p]} return set l $f.$field#l set u $f.$field#u set subform $method set metadata [my meta getnull $subform $field] set argsdata [::tool::args_to_options {*}$args] dict set formdata subform $method dict set formdata field $field dict set formdata post_command [namespace code [list my meta set $subform %field% %value%]] set value [my meta getnull $subform $field value] set objname [my FormObject ::taotk::ui::element.tk $metadata $argsdata $formdata] $objname tkdraw $p $value $objname tklabel $l [$objname cget label $field] [$objname cget description] $objname tklabel $u [$objname cget units] grid $l $p $u -sticky news grid configure $u -sticky news grid configure $l -sticky news grid configure $p -padx 2 -sticky news grid columnconfigure $f $l -minsize 200 grid columnconfigure $f $p -minsize 400 return $objname } # title: Display a dynamic widget representing an option method form::option {f field args} { set p $f.$field if {[winfo exists $p]} return set l $f.$field#l set u $f.$field#u set subform option set metadata [my meta getnull $subform $field] set argsdata [::tool::args_to_options {*}$args] dict set formdata field $field dict set formdata post_command [namespace code {my config set %field% %value%}] dict set formdata subform $subform if {[dict exists $argsdata value]} { set value [dict get $argsdata value] } else { set value [my cget $field] } set objname [my FormObject ::taotk::ui::element.tk $metadata $argsdata $formdata] $objname tkdraw $p $value $objname tklabel $l [$objname cget label $field] [$objname cget description] $objname tklabel $u [$objname cget units] grid $l $p $u -sticky news grid configure $u -sticky news grid configure $l -sticky news grid configure $p -padx 2 -sticky news grid columnconfigure $f $l -minsize 200 grid columnconfigure $f $p -minsize 400 return $objname } } ### # END: form.tcl ### ### # START: stylesheet.tcl ### option add *highlightThickness 0 ### # topic: 8557f63e6b7b9ec1ffec6791db74c7828276f24b |
︙ | ︙ | |||
504 505 506 507 508 509 510 | set has_consolas [expr {"Consolas" in [font families]}] if {$has_consolas} { switch $::tao::platform { macosx { switch $field { font-fixed {return {Consolas 10}} font-button-fixed {return {Consolas 10}} | | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | set has_consolas [expr {"Consolas" in [font families]}] if {$has_consolas} { switch $::tao::platform { macosx { switch $field { font-fixed {return {Consolas 10}} font-button-fixed {return {Consolas 10}} font-button-small {return {Consolas 10}} font-button-bold {return {Consolas 8 bold}} font-canvas {return {Consolas 10}} font-popups {return {Consolas 10}} } } default { switch $field { font-fixed {return {Consolas 10}} |
︙ | ︙ | |||
1015 1016 1017 1018 1019 1020 1021 | } option height { default 5 mirror text } option font { mirror text | | | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | } option height { default 5 mirror text } option font { mirror text type font default TkDefaultFont description {Base display font} } option wrap { mirror text widget select values {none char word} |
︙ | ︙ | |||
1210 1211 1212 1213 1214 1215 1216 | superclass string option state { mirror entry widget select values {normal readonly disabled} default readonly } | | | | 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | superclass string option state { mirror entry widget select values {normal readonly disabled} default readonly } method CalculateValueWidth values { set w 0 set n 0 foreach v $values { incr n set l [string length $v] incr bins($l) if {$l > $w} { set w $l } } if { $w > 30} { set w 30 } if {$w < 10} { return 10 } return [expt {$w+1}] } method Widget_Edit {} { if {[my EnterMode edit window varname]} return set values [my CalculateValues] if {[my readonly]} { ::ttk::label $window.m -style [my Style label] -textvariable $varname -width [my CalculateValueWidth $values] pack $window.m -side left -expand 1 -fill x return |
︙ | ︙ | |||
1260 1261 1262 1263 1264 1265 1266 | pack $window.e -side left } bind $window.e <KeyRelease-Return> [namespace code "my validate"] bind $window.e <KeyPress-Escape> [namespace code {my display}] bind $window.e <<ComboboxSelected>> [namespace code "my validate"] #after idle [list ::ttk::combobox::Post $window.e] } | | | 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | pack $window.e -side left } bind $window.e <KeyRelease-Return> [namespace code "my validate"] bind $window.e <KeyPress-Escape> [namespace code {my display}] bind $window.e <<ComboboxSelected>> [namespace code "my validate"] #after idle [list ::ttk::combobox::Post $window.e] } noop method Widget_Subform {tkpath varname} { set opts [list -textvariable ${varname} -width [my cget width]] set wstate [my cget state] set values [my CalculateValues] ::ttk::combobox $tkpath -style [my Style combobox] {*}$opts -takefocus 1 \ -state $wstate -values $values my graft mainframe $tkpath hullwidget $tkpath hull $tkpath nativewidget $tkpath |
︙ | ︙ | |||
1282 1283 1284 1285 1286 1287 1288 | } # description: A {pick from a finite list} widget ::taotk::ui::element register combobox { superclass select | | | 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 | } # description: A {pick from a finite list} widget ::taotk::ui::element register combobox { superclass select method Widget_Edit {} { if {[my EnterMode edit window varname]} return if {[my readonly]} { ::ttk::label $window.m -style [my Style label] -textvariable $varname -width [my cget width] pack $window.m -side left -expand 1 -fill x return } |
︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | bind $window.e <KeyRelease-Return> [namespace code {my validate}] bind $window.e <<ComboboxSelected>> [namespace code {my validate}] #ttk::combobox::Post $window.e } } | | | 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | bind $window.e <KeyRelease-Return> [namespace code {my validate}] bind $window.e <<ComboboxSelected>> [namespace code {my validate}] #ttk::combobox::Post $window.e } } tool::define ::taotk::ui::element::history { superclass select meta set is claim: {[dict getnull $info history] eq 1} option state { widget select values {normal readonly disabled} default normal } |
︙ | ︙ | |||
1359 1360 1361 1362 1363 1364 1365 | # -validatecommand [namespace code {my Validate %P}] \ # -validate focusout \ # -invalidcommand [namespace code {my ErrorInvalid %P}] # * Does not work at present, consitently returns "Error 1" #### ttk::button $window.b \ -text SAVE -style [my Style button small] \ | | | | | | 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 | # -validatecommand [namespace code {my Validate %P}] \ # -validate focusout \ # -invalidcommand [namespace code {my ErrorInvalid %P}] # * Does not work at present, consitently returns "Error 1" #### ttk::button $window.b \ -text SAVE -style [my Style button small] \ -command [namespace code {my validate}] ttk::button $window.rand \ -text RAND -style [my Style button small] \ -command [namespace code {my Validate [::tao::uuid_short]}] ttk::button $window.x \ -text CANCEL -style [my Style button small] \ -command [namespace code {my Widget_Display}] \ -balloon {Cancel [Esc]} bind $window.m <Key-Return> [namespace code {my validate}] bind $window.m <Key-Escape> [namespace code {my Widget_Display}] pack $window.x $window.b $window.rand -side right -fill y my graft nativewidget $window.m pack $window.m -side left -expand 1 -fill x focus $window.m $window.m icursor end #bind $window <Leave> [namespace code {my Widget_Display}] } } ### # END: string.tcl ### ### # START: textpopup.tcl ### |
︙ | ︙ | |||
1409 1410 1411 1412 1413 1414 1415 | if {[my EnterMode edit window varname]} return set readonly [my readonly] set label View my graft button $window.button ::ttk::button $window.button -style [my Style button small [my cget row]] -text $label -command [namespace code {my InvokePopup}] grid $window.button -sticky news } | | | | | | | | 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | if {[my EnterMode edit window varname]} return set readonly [my readonly] set label View my graft button $window.button ::ttk::button $window.button -style [my Style button small [my cget row]] -text $label -command [namespace code {my InvokePopup}] grid $window.button -sticky news } method initialize {} { my graft text ::noop } method InvokePopup {} { package require ctext set w [my widget subwindow popup] destroy $w set readonly [my readonly] set field [my cget field] toplevel $w wm title $w [list Editing $field] #[winfo toplevel [my organ nativewidget]] my graft text $w.t ttk::label $w.l -text "Editing $field" ctext $w.t -yscrollcommand "$w.vsb set" -xscrollcommand "$w.hsb set" \ -width 70 -wrap none -font [::taotk::stylesheet cget font-editor] ttk::scrollbar $w.vsb -orient vertical -command "$w.t yview" ttk::scrollbar $w.hsb -orient horizontal -command "$w.t xview" my Highlight my <text> delete 0.0 end my <text> insert 0.0 [my Value_Display [my Value_Get]] ttk::frame $w.b -style [my Style frame] ttk::button $w.b.save -text "Save" -command [namespace code {my validate}] ttk::button $w.b.close -text "Close" -command "destroy $w" ttk::sizegrip $w.b.sizegrip if {!$readonly} { pack $w.b.save -side left -fill y } pack $w.b.sizegrip $w.b.close -side right -fill y pack $w.l -side top -fill x pack $w.b -side bottom -fill x pack $w.hsb -side bottom -fill x -padx [list 0 [winfo reqwidth $w.vsb]] pack $w.t -side left -fill both -expand 1 pack $w.vsb -side left -fill y } |
︙ | ︙ | |||
1860 1861 1862 1863 1864 1865 1866 | option offer_reset {default 0} option reset_value {default {}} method ApplySelectedValue newvalue { set varname [my cget textvariable] set $varname $newvalue } | | | 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 | option offer_reset {default 0} option reset_value {default {}} method ApplySelectedValue newvalue { set varname [my cget textvariable] set $varname $newvalue } # Implement a subform instance method form_edit {tkpath varname fconfig} { destroy $tkpath set opts [list -textvariable ${varname} -width [my cget width]] switch [dict getnull $fconfig type] { select { ::ttk::combobox $tkpath {*}$opts -values [if_null [dict getnull $fconfig values] [dict getnull $fconfig options]] -state readonly |
︙ | ︙ | |||
1882 1883 1884 1885 1886 1887 1888 | foreach key {<Return>} { bind [my organ nativewidget] $key [namespace code {my validate}] } foreach key {<Escape>} { bind [my organ nativewidget] $key [namespace code {my <form> display}] } } | | | | | | | | | 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 | foreach key {<Return>} { bind [my organ nativewidget] $key [namespace code {my validate}] } foreach key {<Escape>} { bind [my organ nativewidget] $key [namespace code {my <form> display}] } } method Widget_Get {} { my variable displayvalue set w [my organ nativewidget] if {[winfo exists $w]} { set displayvalue [$w get] } return $displayvalue } method get {} { set value [my Widget_Get] return $value } } ::taotk::ui::element register vector { superclass string ::taotk::meta::form meta set const wide_field: 1 option command {default {}} option delimeter {default ", "} method SubElement {field tkpath varname args} { my variable subobj_map set fconfig [dict merge {*}$args] set objname [info object namespace [self]]::$field dict set fconfig field $field dict set fconfig row [my cget row] dict set fconfig textvariable $varname if {[info command $objname] eq {}} { ::taotk::ui::element.vector create $objname } $objname attach [list form [self]] $fconfig $objname form_edit $tkpath $varname $fconfig return $objname } method Widget_Get {} { my variable formelement_fields local_array set result [array get local_array] foreach {obj field} $formelement_fields { dict set result $field [$obj get] } return $result } method Widget_Edit {} { if {[my EnterMode edit window varname]} return set subobj_map {} set readonly [my readonly] set vectorvar [my varname local_array] set labelrow {} set widgetrow {} set row [if_null [my cget row] 0] ttk::frame $window.m -style [my Style frame] foreach {vfield vfieldinfo} [my Vector_Fields] { ttk::label $window.m.$vfield#l -style [my stylesheet widget_style label {} $row] -text "$vfield:" set subobj [my SubElement $vfield $window.m.$vfield ${vectorvar}($vfield) {widget entry} $vfieldinfo] dict set subobj_map $vfield $subobj lappend labelrow $window.m.$vfield#l lappend widgetrow $window.m.$vfield } grid {*}$labelrow -sticky news grid {*}$widgetrow -sticky news pack $window.m ttk::button $window.b \ -text SAVE -style [my Style button small] \ |
︙ | ︙ | |||
1965 1966 1967 1968 1969 1970 1971 | ttk::button $window.null \ -text RESET -style [my Style button small] \ -command [namespace code [list my Widget_Reset_Value]] pack $window.x $window.b $window.null -side right -fill y } else { pack $window.x $window.b -side right -fill y } | | | | | | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 | ttk::button $window.null \ -text RESET -style [my Style button small] \ -command [namespace code [list my Widget_Reset_Value]] pack $window.x $window.b $window.null -side right -fill y } else { pack $window.x $window.b -side right -fill y } my graft nativewidget $window.m pack $window.m -side left -expand 1 -fill x [lindex $subobj_map 1] widget focus } method Widget_Reset_Value {} { my Validate [my cget reset_value] my Widget_Display my Value_Display [my cget reset_value] } } ::taotk::ui::element register physics { superclass string method Widget_Edit {} { if {[my EnterMode edit window varname]} return if {[string is integer -strict [my cget width]]} { lappend opts -width [my cget width] } destroy {*}[winfo children $window] my variable irm_value system_units user_value system_options ttk::label $window.irm -textvariable [my varname irm_value] -width 6 \ -style [my Style label] ttk::entry $window.m -textvariable [my varname user_value] -width 10 \ -style [my Style entry] set options [my cget options] ttk::combobox $window.userunit -textvariable [my varname user_units] -width 20 \ -style [my Style combobox] -values $system_options bind $window.userunit [namespace code {my Change_Units}] # -validatecommand [namespace code {my Validate %P}] \ # -validate focusout \ # -invalidcommand [namespace code {my ErrorInvalid %P}] # * Does not work at present, consitently returns "Error 1" #### ttk::button $window.b \ |
︙ | ︙ | |||
2021 2022 2023 2024 2025 2026 2027 | ttk::button $window.null \ -text NULL -style [my Style button small] \ -command [namespace code {my Widget_Reset_Value}] pack $window.x $window.b $window.null -side right -fill y } else { pack $window.x $window.b -side right -fill y } | | | 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 | ttk::button $window.null \ -text NULL -style [my Style button small] \ -command [namespace code {my Widget_Reset_Value}] pack $window.x $window.b $window.null -side right -fill y } else { pack $window.x $window.b -side right -fill y } my graft nativewidget $window.m pack $window.irm $window.m $window.userunit -side left -expand 1 -fill x focus $window.m $window.m icursor end } method Widget_Get {} { |
︙ | ︙ | |||
2063 2064 2065 2066 2067 2068 2069 | if {![info exists $variable]} { set label Create } elseif {[set $variable] eq {}} { set label Create } } ::ttk::button $p -style [my Style button small] -text $label -command [namespace code {my popup}] | | | 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 | if {![info exists $variable]} { set label Create } elseif {[set $variable] eq {}} { set label Create } } ::ttk::button $p -style [my Style button small] -text $label -command [namespace code {my popup}] xylist_window $p $field $array $readonly" } method popup {} {} } ### |
︙ | ︙ |