I want to create a window with two text boxes one on top of another with first occupying 25% of height and next occupying 75% of height.
I tried to calculate relative height/width of toplevel win and pass into text command but didn't work (I am guessing because the units of dimension returned by wm geometry is not the same as when passed to text command)
Following is my code:
toplevel .t
wm geometry .t 1500x800+10+10
update
proc topAspect {args} {
regexp {(\d+)} $args -> relAspect
regexp {([^\d|%]+)} $args -> aspect
regexp {(.*)x(.*)[+-](.*)[+-](.*)} [wm geometry .t] -> width height x y
puts "width->$width height->$height x->$x y->$y"
switch -regexp [string tolower $aspect] {
x {
return [expr $x + $relAspect]
}
y {
return [expr $y + $relAspect]
}
w {
return [expr $width * $relAspect / 100]
}
h {
return [expr $height * $relAspect / 100]
}
default {
log::log error "Unsupported relative aspect $aspect cannot be determined for top level window"
}
}
}
text .t.text1 -height [topAspect -width 25%] -width [topAspect -width 99%]
grid .t.text1 -sticky news
text .t.text2 -height [topAspect -width 75%] -width [topAspect -width 99%]
grid .t.text2 -sticky news
When I tried following - it did give me some decent GUI:
text .t.text1 -height 20 -width [topAspect -width 99%]
grid .t.text1 -sticky news
text .t.text2 -height 20 -width [topAspect -width 99%]
grid .t.text2 -sticky news
But i want to use the relative options. How to make it work?