tcltk-toolkit

TCL TK, how to add a scroll bar


I have this procedure that create a windows that display a list of scenario to be executed. a list is displayed with for buttons (check all, uncheckall, ok, annuler) and we are able to check items in the list. the problem I have with this windows is that there is no scroll bar. either in x, and in y.

it means that is the name of the scenario are too long, we can't see the complete text nor see the square to check. also if the number of scenario is too high, we can't see the complete list in the windows.

Do you know if it is easy to add scrollbar in x and y for this windows ?

Here is the windows :

enter image description here

Here is the code :

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

Solution

  • This looks like you are using the Dialog box from the BWidget extension. It's not normal to have scrollbars on a pop-up dialog and I don't see any option to do that.

    It does look like you could set the dialog window to be bigger, which might avoid this problem. I don't know what size you will need, but if you needed width=800 and height=600 you could add

    $dlg configure -geometry 800x600
    

    after the first line where you create the dialog. Documentation is at https://tcllib.sourceforge.net/BWman/Dialog.html#-geometry and https://www.tcl-lang.org/man/tcl8.6/TkCmd/wm.htm#M42