要查找使用的样式特定窗口小部件使用winfo class
命令:
% ttk::checkbutton .b
% winfo class .b
TCheckbutton
然后你可以转储使用ttk::style layout
布局:(重新格式化为可读性)
% ttk::style layout TCheckbutton
Checkbutton.padding -sticky nswe -children {
Checkbutton.indicator -side left -sticky {}
Checkbutton.focus -side left -sticky w -children {
Checkbutton.label -sticky nswe
}
}
这声明了元素以及它们如何放置。所以更换indicator
元素,您可以复制此布局定义一个新的布局,它引用您的新元素:
% ttk::style layout Pin.TCheckbutton {
Checkbutton.padding -sticky nswe -children {
Checkbutton.pin -side left -sticky {}
Checkbutton.focus -side left -sticky w -children {
Checkbutton.label -sticky nswe
}
}
}
% place [ttk::checkbutton .pin -text text -style Pin.TCheckbutton] -x 10 -y 10
你应该注意的一些内容拿起连接到样式的附加配置由ttk::style configure
命令,以便复制一个风格时,你也应该复制的配置:
ttk::style configure $new_stylename {*}[ttk::style configure $old_stylename]
和小窗口状态的最有可能也地图(ttk::style map
)。
读取<Tcl/Tk folder>/library/ttk
中的ttk库文件应该显示很多关于这些东西是如何放在一起的。 vsapi.tcl文件特别为Windows做了相当多的布局。
祝你好运。我必须阅读源代码才能发现... –