# -Q2.D.4- avoid fractional white space at the end of a resizable listbox?

    From: -II-  Tk Questions and Answers - How can I:

    A2.D.4. First, let's state the problem more clearly. I want to make a
    resizable listbox and I don't want to constrain it by setting a
    minimum size. So I pack it with fill expand, I use it to set the grid
    (so that resizing the window always gives me whole lines) and I set an
    initial geometry of 1x1 to override the default. However what I get
    is... (run the code below for a demo and try to resize)

    listbox .l -geom 1x1 -setgrid 1 -yscrollcommand ".s set" -relief sunken -bd 2
    scrollbar .s -command ".l yview"
    pack .s -side right -fill y
    pack .l -side top -fill both -expand 1
    .l insert end one two three four five six seven eight nine ten "THE END"

    ...a situation where the partially filled listbox has a blank
    half-line at the bottom even if there are more items in the list. This
    is very confusing because it fools the user into thinking that there
    is nothing else beyond what's visible. Why does it happen?

    Now for the answer.
    	Look at the window as it is created, before the resizing. See that
    poor, tiny little scrollbar squeezed in that microscopic window? It,
    too, requests a minimum size, and it so happens that the starting
    geometry for the listbox (i.e. the situation referred to as "1x1")
    receives some free fractional space at the bottom. And you never get
    rid of it, since the resizing is constrained to be in whole
    characters.

    The thing to do is to define the initial layout in such a way that the
    widget that has -setgrid actually displays an integer number of lines
    and columns. In the above example, setting -geom 1x2 does the trick.

    Thanks to Frank Stajano <fms@cam-orl.co.uk> for this tip.

Parent document is top of "FAQ: comp.lang.tcl Tk Toolkit Usage Questions And Answers (1/1)"
Previous document is "-Q2.D.3- select items in more than one Tk listbox at a time?"
Next document is "-Q2.D.5- scroll two listboxes with one scrollbar?"