Problems with the remove child command resolved. This will be more useful when toggling the display of UI items. If the -visible option is used to manipulate object, space will still be allocated for the hidden object. This may be acceptable at times, but in large, complex layouts hiding already packed widgets may alter the overall window sizing or affect the relative sizing of other containers such as the gnocl::paned widget.
Test script:
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
package require Gnocl
proc swap_parent {w} {
global box
set p [$w parent]
if {$p eq $box(1)} {
$box(1) remove $w
$box(2) add $w -fill {1 1} -expand 1
} else {
$box(2) remove $w
$box(1) add $w -fill {1 1} -expand 1
}
}
set box(1) [gnocl::box]
set box(2) [gnocl::box]
set win(1) [gnocl::window -title "Window #1" -x 100 -child $box(1) -width 200 -height 100]
set win(2) [gnocl::window -title "Window #2" -x 400 -child $box(2) -width 200 -height 100]
set but(1) [gnocl::button -text "Click-Me!" -onClicked {swap_parent %w}]
$box(1) add $but(1) -fill {1 1} -expand 1
Test script:
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
package require Gnocl
proc swap_parent {w} {
global box
set p [$w parent]
if {$p eq $box(1)} {
$box(1) remove $w
$box(2) add $w -fill {1 1} -expand 1
} else {
$box(2) remove $w
$box(1) add $w -fill {1 1} -expand 1
}
}
set box(1) [gnocl::box]
set box(2) [gnocl::box]
set win(1) [gnocl::window -title "Window #1" -x 100 -child $box(1) -width 200 -height 100]
set win(2) [gnocl::window -title "Window #2" -x 400 -child $box(2) -width 200 -height 100]
set but(1) [gnocl::button -text "Click-Me!" -onClicked {swap_parent %w}]
$box(1) add $but(1) -fill {1 1} -expand 1
Comments