TCL TK,如何添加滚动条

问题描述 投票:0回答:1

我有这个过程创建一个窗口,显示要执行的场景列表。显示一个带有按钮的列表(选中全部、取消选中、确定、取消),我们可以检查列表中的项目。 我使用这个窗口的问题是没有滚动条。要么在 x 中,要么在 y 中。

这意味着场景名称太长,我们看不到完整的文本,也看不到要检查的方块。 另外,如果场景数量太多,我们无法在窗口中看到完整的列表。

你知道在这个窗口的 x 和 y 中添加滚动条是否容易吗?

这是窗户:

这是代码:

set dlg [Dialog .new -anchor n -place center -side right -cancel 6 -default 0 -parent . -modal local \
     -transient 0]
# place this button first because it is default value (-default 0)
$dlg add -text "check all" -underline 2 -command {run_simu_check_all}
$dlg add -text "uncheck all" -underline 2 -command {run_simu_uncheck_all}
# when "ok" is hit, windows is closed and tests are run (another windows will be open)
$dlg add -text "OK" -underline 2 -command {.new enddialog "";pexecute_simu_script $Cockpit::bf}

# this button is placed in last place because it is the choosen value (-cancel 5) if we cancel (esc key)
$dlg add -text "  Annuler  " -underline 2 -command {.new enddialog ""}

set frame [frame [$dlg getframe].frame]
    set label [label $frame.label]
    pack $label -side top -anchor n -fill x -expand 1
pack $frame -fill both -expand 1

# checkbox display for each scenario 
set liste_entite [liste_entite $Cockpit::bf fic_simu_modtb_comp]
foreach entite $liste_entite {
    if {$entite != "NONE"} {
        global ${entite}_var
        if {![info exists ${entite}_var]} {set ${entite}_var 0}
        # we use -side top so that checkbutton be in column from up to down
        pack [checkbutton $frame.$entite \
                    -text "$entite" \
                    -font {arial 8} \
                    -width 50\
                    -justify left \
                    -variable ${entite}_var \
                    -command {} \
                   ] -side top
    }
}

.new configure -title "choose scenario to run"
[.new getframe].frame.label configure -text "select scenario to run"

wm iconbitmap .new $Cockpit::icon
.new draw
tcl tk-toolkit
1个回答
0
投票

这看起来您正在使用 BWidget 扩展中的对话框。弹出对话框上有滚动条是不正常的,我没有看到任何选项可以做到这一点。

看起来您确实可以将对话框窗口设置得更大,这可能会避免此问题。我不知道你需要什么尺寸,但如果你需要宽度=800和高度=600,你可以添加

$dlg configure -geometry 800x600

在创建对话框的第一行之后。 文档位于 https://tcllib.sourceforge.net/BWman/Dialog.html#-geometryhttps://www.tcl-lang.org/man/tcl8.6/TkCmd/wm.htm#M42

© www.soinside.com 2019 - 2024. All rights reserved.