tcltk创建scrollbar在treeview中

19 篇文章 2 订阅
17 篇文章 6 订阅

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值