From: rolance on
Hi All

I will write a program to achieve mark some area without user mouse
or keyboard affect like grab command

and the child window must move , iconify follow with main window!

could some one give me direction to achieve


some code below:

toplevel .child
set parent .
set child .child
wm attributes $child -transparentcolor blue


# This should display $child centered in $parent
set w [winfo width $parent]
set h [winfo height $parent]
set x [winfo rootx $parent]
set y [winfo rooty $parent]
set xpos "+[ expr {$x+($w-[winfo width $child])/2}]"
set ypos "+[ expr {$y+($h-[winfo height $child])/2}]"

wm geometry $child "$xpos$ypos"

this child window mark center without user focus in but still see
under widget {child window -bg blue}

How to control child windows move with parent window? child always
locate in fix area with parent window!

BR
Rolance
From: Donald Arseneau on
On Feb 23, 2:05 am, rolance <tomstone...(a)hotmail.com> wrote:

> I will write a program to achieve  mark some area without > user mouse or keyboard affect like grab command
> and the child window must move , iconify follow with main
> window!

Do you want to eliminate the window-manager controls
entirely from the child window? Then specify

wm overrideredirect .child 1


>    # This should display $child centered in $parent
> ...
>    wm geometry $child "$xpos$ypos"

Put that in a proc (proc center_child ...) so you can
recenter the child. Then

bind .parent <Configure> center_child

You can also use bindings to control iconifying the
child window (bind to <Map> and <Unmap> events) but
I suppose it is probably better to declare the child
as "transient" and let the user preferences rule the
iconification.

Donald Arseneau
From: rolance on
On 2月24日, 上午5時26分, Donald Arseneau <a...(a)triumf.ca> wrote:
> On Feb 23, 2:05 am, rolance <tomstone...(a)hotmail.com> wrote:
>
> > I will write a program to achieve  mark some area without > user mouse or keyboard affect like grab command
> > and the child window must move , iconify follow with main
> > window!
>
> Do you want to eliminate the window-manager controls
> entirely from the child window? Then specify
>
> wm overrideredirect .child 1
>
> >    # This should display $child centered in $parent
> >    ...
> >    wm geometry $child "$xpos$ypos"
>
> Put that in a proc (proc center_child ...) so you can
> recenter the child.  Then
>
> bind .parent <Configure> center_child
>
> You can also use bindings to control iconifying the
> child window (bind to <Map> and <Unmap> events) but
> I suppose it is probably better to declare the child
> as "transient" and let the user preferences rule the
> iconification.
>
> Donald Arseneau


Dear Donald Arseneau

thanks for your advise!

BR
Rolance
From: Donald Arseneau on
On Feb 23, 2:05 am, rolance <tomstone...(a)hotmail.com> wrote:
>    set parent .

oops, I just noticed this. You have to be careful binding
to the "." toplevel because its bindings normally apply to
every single widget! If your parent is some other window,
such as .parent, then the binding is simple, otherwise you
need some testing, like

proc centerchild { parent child win } {
if { $win eq $parent } {
# This should display $child centered in $parent
set w [winfo width $parent]
set h [winfo height $parent]
set x [winfo rootx $parent]
set y [winfo rooty $parent]
set xpos "+[ expr {$x+($w-[winfo width $child])/2}]"
set ypos "+[ expr {$y+($h-[winfo height $child])/2}]"
wm geometry $child "$xpos$ypos"
}
}

bind . <Configure> [list centerchild $parent $child %W]


From: rolance on
On 2月24日, 上午9時14分, Donald Arseneau <a...(a)triumf.ca> wrote:
> On Feb 23, 2:05 am, rolance <tomstone...(a)hotmail.com> wrote:
>
> >    set parent .
>
> oops, I just noticed this.  You have to be careful binding
> to the "." toplevel because its bindings normally apply to
> every single widget!  If your parent is some other window,
> such as .parent, then the binding is simple, otherwise you
> need some testing, like
>
> proc centerchild { parent child win } {
>  if { $win eq $parent } {
>    # This should display $child centered in $parent
>    set w [winfo width $parent]
>    set h [winfo height $parent]
>    set x [winfo rootx $parent]
>    set y [winfo rooty $parent]
>    set xpos "+[ expr {$x+($w-[winfo width $child])/2}]"
>    set ypos "+[ expr {$y+($h-[winfo height $child])/2}]"
>    wm geometry $child "$xpos$ypos"
>  }
>
> }
>
> bind . <Configure> [list centerchild $parent $child %W]


when I eliminate the window-manager controls entirely from the child
window

use:

wm overrideredirect .child 1


the child windows don't appear, any detail info I miss?

BR
Rolance