实例创建scrollbar在treeview中
ttk::treeview .tree -yscrollcommand {.vsb set}
pack .tree -side left
#ttk::scrollbar .tree.hsb -orient horizontal -command {}
.tree insert {} end -id "Metal" -text "Metal"
.tree insert {} end -id "Composite" -text "Composite"
.tree insert {} end -id "Fluid" -text "Fluid"
.tree insert "Metal" end -id "1025 " -text "1025 "
.tree insert "Metal" end -id "2024-O " -text "2024-O "
.tree insert "Metal" end -id "2024-T3 " -text "2024-T3 "
.tree insert "Metal" end -id "2024-T4 " -text "2024-T4 "
.tree insert "Metal" end -id "2024-T62" -text "2024-T62"
.tree insert "Metal" end -id "7075-O " -text "7075-O "
.tree insert "Metal" end -id "7075-T6 " -text "7075-T6 "
.tree insert "Metal" end -id "7075-T73" -text "7075-T73"
ttk::scrollbar .vsb -orient vertical -command {.tree yview}
pack .vsb -side right -fill y -expand 1
右键实例
ttk::treeview .tree -yscrollcommand {.vsb set}
pack .tree -side left
#ttk::scrollbar .tree.hsb -orient horizontal -command {}
.tree insert {} end -id "Metal" -text "Metal"
.tree insert {} end -id "Composite" -text "Composite"
.tree insert {} end -id "Fluid" -text "Fluid"
.tree insert "Metal" end -id "1025 " -text "1025 "
.tree insert "Metal" end -id "2024-O " -text "2024-O "
.tree insert "Metal" end -id "2024-T3 " -text "2024-T3 "
.tree insert "Metal" end -id "2024-T4 " -text "2024-T4 "
.tree insert "Metal" end -id "2024-T62" -text "2024-T62"
.tree insert "Metal" end -id "7075-O " -text "7075-O "
.tree insert "Metal" end -id "7075-T6 " -text "7075-T6 "
.tree insert "Metal" end -id "7075-T73" -text "7075-T73"
ttk::scrollbar .vsb -orient vertical -command {.tree yview}
pack .vsb -side right -fill y -expand 1
catch {destroy .msgTrackerPopupmenu}
menu .msgTrackerPopupmenu -tearoff 0
.msgTrackerPopupmenu add cascade -label Elements -command {check}
.msgTrackerPopupmenu add cascade -label Nodes
.msgTrackerPopupmenu add cascade -label Properties
bind .tree "<Button-3>" "showPopMenu %X %Y"
proc showPopMenu {x y} {
tk_popup .msgTrackerPopupmenu $x $y
}
proc check {} {
set selectItem [.tree selection]
tk_messageBox -message "Select $selectItem"
}