I'm confused, with such a situtation. I made a small code, which functions as expected. See:
#!/bin/ash
# \
exec tclsh $0 "$@"
package require Tk
wm withdraw .
toplevel .top
pack [frame .top.frmBase0 -bg white] -side top -anchor center -fill both -expand true -padx 0 -pady 0
set frame .top.frmBase0.palco
text $frame -borderwidth 0 -highlightthickness 0 -relief flat -bg #efefef
pack $frame -side right -anchor nw -fill both -expand true -ipadx 10 -ipady 0
pack [frame $frame.pnl0 -bg darkred] -side left -anchor nw -padx 5 -pady 5
pack [button $frame.pnl0.btn0 -text "Lorem ipsum"] -side top -anchor center
pack [label $frame.pnl0.lbl0 -text "String" -justify left -bg darkred -fg whitesmoke -font {-family courier -size 8 -weight bold}] -side left -anchor nw -padx 5 -pady 5
$frame.pnl0.btn0 config -highlightbackground [$frame.pnl0 cget -background]
Result print:
But when trying, write it otherwise using: $frame window create end -window $frame.pnl0.btn0
#!/bin/ash
# \
exec tclsh $0 "$@"
package require Tk
wm withdraw .
toplevel .top
pack [frame .top.frmBase0 -bg white] -side top -anchor center -fill both -expand true -padx 0 -pady 0
set frame .top.frmBase0.palco
text $frame -borderwidth 0 -highlightthickness 0 -relief flat -bg #efefef
pack $frame -side right -anchor nw -fill both -expand true -ipadx 10 -ipady 0
pack [frame $frame.pnl0 -bg darkred] -side left -anchor nw -padx 5 -pady 5
label $frame.pnl0.lbl0 -text "String" -justify left -bg darkred -fg whitesmoke -font {-family courier -size 8 -weight bold}
button $frame.pnl0.btn0 -font {-family courier -size 12 -weight bold} -text "Lorem ipsum"
$frame.pnl0.btn0 config -highlightbackground [$frame.pnl0 cget -background]
$frame window create end -window $frame.pnl0 -padx 20 -pady 20 -stretch 1
$frame window create end -window $frame.pnl0.btn0
$frame window create end -window $frame.pnl0.lbl0
Generated the following error:
The problem is here, when put .pnl0 between $frame and .lbl0
When putting widgets inside a text widget (or a canvas) as items, it's important to make the widgets that you put in be direct children of the container widget. Without that, clipping doesn't work right and things can behave weirdly.
In your case, the widget that you are putting directly in the text widget should be the frame $frame.pnl0
, and the button and label should be packed (or gridded, or placed, or whatever) inside that.
# Make widgets for panel
set panel [frame $frame.pnl0 -bg darkred]
button $panel.btn0 -text "Lorem ipsum"
label $panel.lbl0 -text "String" -justify left -bg darkred -fg whitesmoke \
-font {-family courier -size 8 -weight bold}
$panel.btn0 config -highlightbackground [$panel cget -background]
# Arrange widgets for panel
pack $panel.btn0 -side top -anchor center
pack $panel.lbl0 -side left -anchor nw -padx 5 -pady 5
$frame window create end -window $panel -padx 20 -pady 20 -stretch 1