Unfortunately, I've not encountered any "off-the-shelf" code for doing what you requested,
sh00der. There are some
toolbar implementations out there (for example, see "toolbar,"
on the Tcl'ers Wiki), but they don't handle dynamic resizing of their tool-buttons. They don't even seem to handle "wrapping" buttons to an additional column/row, if needed.
So, it looks as though you're going to have to come up with a solution yourself. One path would be to track the information "manually" as you add buttons to your taskbar, and then switch to a condensed form or start wrapping to another row once you've reached a certain number. Another would be to create a binding to your frame's [tt]<Configure>[/tt] event, which is fired when the widget is mapped to the screen and whenever it changes size. With a binding like this:
Code:
bind .taskbar <Configure> {TaskbarConfigure %W %w %h}
your code would call
TaskbarConfigure whenever its size changed, passing the widget name and its width and height in pixels. You could then adjust as needed, but you'd need to be careful not to fall into an endless configuration loop, where condensing the toolbar would change its size, triggering the binding again, and potentially becoming small enough in size to trigger the decision to expand it again, which would fire the configure binding again, and so on and so on...
By the way, if you do decide to go with a design of wrapping buttons to a second (or third, etc) row, you might want to use the
grid geometry manager for your taskbar's contents instead of
pack.
grid is a natural for managing layouts like this. For example, to
grid your taskbar in rows of no more than 5 buttons each:
Code:
frame .f1
pack .f1
# Note that the -uniform option was introduced in Tk 8.4
grid columnconfigure .f1 {0 1 2 3 4} -weight 1 -uniform A
set bNo 0
foreach model $modList {
button .f1.btn$bNo -text $model -command [list draw $model]
set row [expr {$bNo / 5}]
set column [expr {$bNo % 5}]
grid .f1.btn$bNo -row $row -column $column -sticky nsew -padx 1 -pady 1
incr bNo
}
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax