Tk Source Code

Artifact [cc3ac463]
Login

Artifact cc3ac4632bafde68e9b02244b90672edb9e9f2e0f595f9188e915ab1105e8a02:

Attachment "scrollUtilXX.tcl" to ticket [cde766f9] added by nab 2021-03-10 13:18:39.
package require Tk

proc append_to_autoPath {path} {
    global auto_path
    if {[lsearch -exact $auto_path $path]==-1} {
        lappend auto_path $path
    }
    return $auto_path
}
append_to_autoPath [file nativename [file normalize [file join [file dirname [info nameofexecutable]] ../../../Scripts]]]

package require tablelist
package require scrollutil_tile

catch {namespace delete obj}
namespace eval obj {
    array set obj {}
    variable tblAddress
}

proc fixtble {frame namespace} {

    set f [ttk::frame $frame -class ScrollArea]
    set sa [scrollutil::scrollarea $f.sa]
    set tbl $sa.tbl
 
    tablelist::tablelist $tbl \
    -columns {0 "Column1"          center
        0 "Column2"      center
        5 "Column3"      center
        0 "Column4"      center
        0 "Column5"          center
        0 "Column6"      center
        0 "Column7"      center
        0 "Column8"      center
        0 "a"      center
        0 "b"      center
        0 "c"      center
        0 "d"      center
    } \
    -height 10 -width 50 -selectbackground lightyellow -stretch all -background gray20 -font {TkTextFont 18} \
    -foreground white \
    -labelforeground white -labelbackground black -labelrelief ridge -selectforeground black -labelactivebackground black \
    -labelactiveforeground white -exportselection 1
    
    
    if {[$tbl cget -selectborderwidth] == 0} {
        $tbl configure -spacing 1
    }
    
    set ${namespace}::tblAddress $tbl
    
    $sa setwidget $tbl
    grid $sa -sticky news
    $f configure -borderwidth 1 -relief solid
    $tbl configure -bd -1
    grid rowconfigure $f all -weight 1
    grid columnconfigure $f all -weight 1

    return $f
}



proc addRow {namespace} {
    namespace upvar $namespace tblAddress ltblAddress
    $ltblAddress insertchildren root end [list 0 0 0 0 0 0 0 0 a b c d]
    update idletasks
}

set this [fixtble .f obj]
set b [ttk::button .b -text "addRows2TblList" -command [list addRow obj]]
grid $b -sticky news
grid $this -sticky news

for {set x 0} {$x<=20} {incr x} {
    addRow obj
}