tcltk创建scrollbar在treeview中

来源:互联网 发布:怎样理解计算机端口 编辑:程序博客网 时间:2024/05/07 07:48

实例创建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 1catch {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" }


0 0
原创粉丝点击