Tk Source Code

View Ticket
Login
Ticket UUID: 3519160
Title: Problem with horizontal scroll of treeview
Type: Bug Version: None
Submitter: stefanlei Created on: 2012-04-18 14:36:35
Subsystem: None Assigned To: nobody
Priority: 5 Medium Severity:
Status: Deleted Last Modified: 2012-04-18 21:38:41
Resolution: None Closed By: stefanlei
    Closed on: 2012-04-18 14:38:41
Description:
The horizontal scrollbar for a ttk::treeview does not work as expected (and as it does for a text widget). While initially the scrollbar appears fine and a corresponding fraction of the tree is displayed, this changes after the tree has been displayed once in its full width. Afterwards the scrollbar is and remains forever at 100%, no matter how small a tree width is chosen.
The scroll command specified with the –xscrollcommand option is then always called with additional arguments 0.0 and 1.0.

Problem occurs with Tcl/Tk 8.5.11 on Windows 7 and SuSE Linux.

The following piece of code demonstrates the problem (If you replace ttk::treeview by text everything looks great):

# purpose: test horizontal treeview scrolling

wm withdraw .
toplevel .ft -takefocus 0
wm geometry .ft =80x300+80+80 
ttk::frame .ft.lf
pack .ft.lf -expand yes -fill both
ttk::scrollbar .ft.lf.hs -orient horiz -command ".ft.tf xview"
ttk::scrollbar .ft.lf.vs -command ".ft.tf yview"
ttk::treeview .ft.lf.tf -show tree -xscrollcommand "hscrollf .ft.lf" -yscrollcommand "vscrollf .ft.lf"
grid .ft.lf.tf -row 0 -column 0 -sticky nsew
grid .ft.lf.vs -row 0 -column 1 -sticky ns
grid .ft.lf.hs -row 1 -column 0 -sticky we
grid rowconfig .ft.lf 0 -weight 1
grid columnconfig .ft.lf 0 -weight 1

# populate tree   
foreach node [list " Entry0 " " Entry111111111111 " " Entry22222222222222222222 " " Entry3333333333333333333333333 "] {
    .ft.lf.tf insert {} end -text $node
}

# Vertical scrolling
proc vscrollf {mw first last} {
    if {[expr {$first > 0.0}] || [expr {$last < 1.0}]} {
        grid $mw.vs -row 0 -column 1 -sticky ns
        $mw.vs set $first $last
    } else {catch {after idle grid remove $mw.vs}}
}

# Horizontal scrolling
proc hscrollf {mw first last} {
    puts "f=$first, l=$last"
    if {[expr {$first > 0.0}] || [expr {$last < 1.0}]} {
        grid $mw.hs -row 1 -column 0 -sticky we
        $mw.hs set $first $last
    } else {catch {after idle grid remove $mw.hs}}
}
User Comments: stefanlei added on 2012-04-18 21:38:41:
allow_comments - 1