正在检索tcl/tk应用程序布局结构



有没有办法从tcl/tk应用程序中检索GUI布局的树结构?我正在尝试检索一个屏幕布局,以便将其转换为html/电子应用程序。

任何建议都很好。

小部件层次结构的基本结构可以通过使用winfo children和基本递归来获得:

proc dumpStructure {{w .} {indent ""}} {
puts "$indent[winfo class $w] $w"
foreach configItem [$w configure] {
lassign $configItem name - - def value
if {$def ne $value && $name ne "-command"} {
# Note: we've excluded things that are set to the default and
# also the -command callbacks because they usually look messy
puts "$indent    $name $value"
}
}
foreach child [winfo children $w] {
dumpStructure $child "$indent  "
}
}

请注意,除了textcanvas小部件要复杂得多之外,您可以如何使用每个小部件的configure方法来获得关于它是如何设置的所有信息。(如果你找不到可接受的替代方案,你可能需要重新开发它们。(几何管理配置更为棘手,因为几何管理器没有太多的通用代码(textcanvas在这方面是的特殊,但其他一些也是如此(。

菜单是它们自己的特例,但在实践中可能很容易映射。

最新更新