• toplevel bind

    From Manfred Stelzhammer@21:1/5 to All on Sat Mar 2 13:20:28 2024
    Hello

    ###

    % wm geometry . 400x400
    % . configure -background yellow

    % pack [frame .f1 -container 1] -fill both -expand yes
    % toplevel .top1 -use [winfo id .f1] -background red
    % bind .top1 <Destroy> "puts {DESTROY .top1}"

    % pack [frame .top1.f2 -container 1] -fill both -expand yes

    % toplevel .top2 -use [winfo id .top1.f2] -background green
    % bind .top2 <Destroy> "puts {DESTROY .top2}"



    % destroy .top2

    ## if I destroy .top2 then the output is:
    % DESTROY .top2
    % DESTROY .top1

    Why, I only destroy .top2 I think I only should get:
    % DESTROY .top2

    ## If I run:
    % winfo exist .top1
    ## I get:
    % 1

    ##

    It this a normal behavior?

    Regards

    Manfred

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Mon Mar 4 17:18:28 2024
    * Manfred Stelzhammer <manfred@antispam.at>
    | % wm geometry . 400x400
    | % . configure -background yellow

    | % pack [frame .f1 -container 1] -fill both -expand yes
    | % toplevel .top1 -use [winfo id .f1] -background red
    | % bind .top1 <Destroy> "puts {DESTROY .top1}"

    | % pack [frame .top1.f2 -container 1] -fill both -expand yes

    | % toplevel .top2 -use [winfo id .top1.f2] -background green
    | % bind .top2 <Destroy> "puts {DESTROY .top2}"

    Make both bindings use %W to see which widget exactly gets the event:

    bind .top1 <Destroy> "puts {DESTROY top1/%W}"
    bind .top2 <Destroy> "puts {DESTROY top2/%W}"

    =>
    destroy .top2
    DESTROY top2/.top2
    DESTROY top1/.top1.f2

    So, destroying .top2 alse destroys .top1.f2, but not .top1.
    I have not checked the details of -container and -use, so I can't
    comment on whether that is to be expected...

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Manfred Stelzhammer@21:1/5 to All on Mon Mar 4 22:06:45 2024
    Thank's

    I know that .top1 isn't destroyed, "Puts {DESTROY .top1}" is only for
    testing.
    It looks like .top1 was destroyed, but it wasn't, but the event was
    triggerd.

    Now I use
    wm protocol .top1 WM_DELETE_WINDOW "puts {DESTROY .top1}"
    wm protocol .top1 WM_DELETE_WINDOW "puts {DESTROY .top2}"

    This work for me like expected.

    regards

    Manfred

    Am 04.03.24 um 17:18 schrieb Ralf Fassel:
    * Manfred Stelzhammer <manfred@antispam.at>
    | % wm geometry . 400x400
    | % . configure -background yellow

    | % pack [frame .f1 -container 1] -fill both -expand yes
    | % toplevel .top1 -use [winfo id .f1] -background red
    | % bind .top1 <Destroy> "puts {DESTROY .top1}"

    | % pack [frame .top1.f2 -container 1] -fill both -expand yes

    | % toplevel .top2 -use [winfo id .top1.f2] -background green
    | % bind .top2 <Destroy> "puts {DESTROY .top2}"

    Make both bindings use %W to see which widget exactly gets the event:

    bind .top1 <Destroy> "puts {DESTROY top1/%W}"
    bind .top2 <Destroy> "puts {DESTROY top2/%W}"

    =>
    destroy .top2
    DESTROY top2/.top2
    DESTROY top1/.top1.f2

    So, destroying .top2 alse destroys .top1.f2, but not .top1.
    I have not checked the details of -container and -use, so I can't
    comment on whether that is to be expected...

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)