笔记本ttk关闭选项卡

时间:2015-06-01 15:35:27

标签: tcl ttk bwidget

我想添加一个绑定来关闭我的标签(ttk :: notebook)。 我正在使用OO tcl(面向对象)

我添加了一张图片(图标X),但是当我点击它时,绑定不是coorect?

你能帮我用tcl OO吗? 所以这是我的代码:

oo::define CLASS method setTAB {command} {
my variable m_noteApp

set name [frame "toto"]
$m_noteApp add $name -text "TAB1" -image "close" -compound right
$m_noteApp select $m_noteApp.$command
my set_close_bindings $m_noteApp $m_noteApp.$command }


oo::define CLASS method set_close_bindings {notebook page} {

puts "tcl -- set_close_bindings $notebook, $page"

bind $notebook <ButtonPress-1> [callscript {
    puts "  ButtonRelease %W %x %y"
    # Widget parentW are OK

    set closeImage ""
    catch {set closeImage [%W identify component %x %y]}
    puts "  -- closeImage : $closeImage" 
    # test is always empty, I dont why ! I expect that it will returns the image close. 

    set pressed [%W identify element %x %y]
    puts "  -- %x %y, $pressed" 
    # pressed = "label" why it's not my close icon, I clic on it ?


    set varname [%W.$pressed cget -text]
    puts "  -- $varname" 
    # error : Invalid command  [%W.$pressed cget -text]     

}]   
 bind $notebook <ButtonRelease-1> [callscript {
    puts "  ButtonRelease %W %x %y"
}] }

我正在使用一个例子

0 个答案:

没有答案