sipvinay: hi All,
I am trying to add buttons in the frame Using TCL/Tk language. I am able to create frame and add button in it. the problem is that, if i am keep adding the buttons in the frame then they will not appear in the frame after some count, I wanted them to come in the next line once it reaches to frame size.
Please advise me, what should i do to solve the problem. Thanks in advance.
my code snip:
wm title . "Toolbar Demonstration"
wm geometry . 325x100
set count 0
# adding frame
proc add_frame title {
global frame count w
set frame .frame$count
frame $frame -border 2 -relief groove
label $frame.label -text $title
pack $frame -side left -padx 2 -pady 2 -anchor n -fill x
pack $frame.label -side top -padx 2 -pady 2
incr count
}
# adding button
proc add_button {title} {
global frame count
button $frame.$count -text $title
pack $frame.$count -side left -pady 1 -padx 3 -fill x
incr count
}
# calling the proc.
add_frame "Button Set1"
add_button " B1 "
add_button " B2 "
add_button " B3 "
add_button " B4 "
add_button " B5 "
add_button " B6 "
add_button " B7 "
add_button " B8 "
add_button " B9 "AMG: If I understand you correctly, you want the buttons to automatically wrap depending on the window size. You can use the text widget to accomplish this:
package require Tk
wm title . "Toolbar Demonstration"
wm geometry . 325x100
set count 0
proc add_frame {title} {
global frame
set frame .frame
text $frame -borderwidth 2 -relief groove
$frame tag configure title -justify center
$frame insert end "$title\n" title
pack $frame -padx 2 -pady 2 -fill both -expand 1
}
proc add_button {title} {
global frame count
button $frame.$count -text $title
$frame window create end -window $frame.$count -pady 1 -padx 3 -stretch 1
incr count
}
add_frame "Button Set1"
for {set i 1} {$i <= 9} {incr i} {
add_button " B$i "
}
$frame configure -state disabled