Check-in [64c713d7f4]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:New TIP518: Event on last child unmanaged (follow-up of tip454)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 64c713d7f4e1668a5d346f45b888d56107174cc9622693637b5945f8fa8d0088
User & Date: oehhar 2018-09-22 19:20:20
Context
2018-09-22
19:33
EEscape "<<" in markdown to show it literally check-in: 9e7d404a8b user: oehhar tags: trunk
19:20
New TIP518: Event on last child unmanaged (follow-up of tip454) check-in: 64c713d7f4 user: oehhar tags: trunk
18:06
Added pointer to tip474 documentation check-in: 9924b58416 user: oehhar tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to index.json.

1

2
3
4
5
6
7
8
...
514
515
516
517
518
519
520
521
522
{"tip": {

	"517":{"url":"./tip/517.md","keywords":"tk menu","created":"13-Sept-2018","post-history":"","state":"Voting","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 517: Add -activerelief Configuration Option to the menu widget","author":["Francois Vogel <[email protected]>"],"is-jest":false},
	"516":{"url":"./tip/516.md","vote-closes":"2018-09-26T12 00 00+0100","keywords":"Tcl, TclOO","created":"7-Sept-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 516: More OO Slot Operations","author":["Donal K. Fellows <[email protected]>"],"is-jest":false},
	"515":{"url":"./tip/515.md","vote-closes":"2018-09-26T12 00 00+0100","created":"7-Sept-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 515: Level Value Reform","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"514":{"url":"./tip/514.md","keywords":"Tcl","created":"20-Aug-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 514: Platform differences in handling int/wide","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"513":{"url":"./tip/513.md","keywords":"Tcl,data structure","created":"02-Aug-2017","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 513: Better support for 'agendas' as arrays, dictionaries or lists","author":["Florian Murr <[email protected]>"],"is-jest":false},
	"512":{"url":"./tip/512.md","keywords":"Tcl","created":"25-June-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 512: No stub for Tcl_SetExitProc()","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"511":{"url":"./tip/511.md","vote-closes":"2018-09-26T12 00 00+0100","keywords":"Tcl,threads","created":"14-June-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 511: Implement Tcl_AsyncMarkFromSignal()","author":["Christian Werner <[email protected]>"],"is-jest":false},
................................................................................
	"5":{"url":"./tip/5.md","created":"17-Oct-2000","post-history":"","state":"Final","vote":"Done","tcl-version":"8.4","type":"Project","title":"# TIP 5: Make TkClassProcs and TkSetClassProcs Public and Extensible","author":["Eric Melski <[email protected]>"],"is-jest":false},
	"4":{"url":"./tip/4.md","created":"26-Oct-2000","post-history":"","state":"Draft","vote":"Pending","type":"Informative","title":"# TIP 4: Tcl Release and Distribution Philosophy","discussions-to":"news comp.lang.tcl","author":["Brent Welch <[email protected]>","Donal K. Fellows <[email protected]>","Larry W. Virden <[email protected]>","Larry W. Virden <[email protected]>"],"is-jest":false},
	"3":{"url":"./tip/3.md","created":"14-Sep-2000","post-history":"","state":"Accepted","vote":"Done","type":"Process","title":"# TIP 3: TIP Format","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>"],"is-jest":false},
	"2":{"url":"./tip/2.md","created":"12-Sep-2000","post-history":"","state":"Draft","vote":"Pending","type":"Process","title":"# TIP 2: TIP Guidelines","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>","Don Porter <[email protected]>","Mo DeJong <[email protected]>","Larry W. Virden <[email protected]>","Kevin Kenny <[email protected]>"],"is-jest":false},
	"1":{"url":"./tip/1.md","created":"14-Sep-2000","post-history":"","state":"Active","vote":"No voting","type":"Informational","title":"# TIP 1: TIP Index","author":["TIP Editor <[email protected]>"],"is-jest":false},
	"0":{"url":"./tip/0.md","created":"11-Dec-2000","post-history":"","state":"Final","vote":"Done","type":"Process","title":"# TIP 0: Tcl Core Team Basic Rules","author":["John Ousterhout <[email protected]>"],"is-jest":false},
	"@min": 0,
	"@max": 517
}, "@timestamp": 1537639543}
>







 







|
|
1
2
3
4
5
6
7
8
9
...
515
516
517
518
519
520
521
522
523
{"tip": {
	"518":{"url":"./tip/518.md","keywords":"Tk","created":"22-Sep-2018","post-history":"","state":"Draft","tcl-version":"8.7.0","vote":"Done","type":"Project","title":"# TIP 518: Virtual Event when Last Child is not Managed any more","author":["Harald Oehlmann <[email protected]>"],"is-jest":false},
	"517":{"url":"./tip/517.md","keywords":"tk menu","created":"13-Sept-2018","post-history":"","state":"Voting","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 517: Add -activerelief Configuration Option to the menu widget","author":["Francois Vogel <[email protected]>"],"is-jest":false},
	"516":{"url":"./tip/516.md","vote-closes":"2018-09-26T12 00 00+0100","keywords":"Tcl, TclOO","created":"7-Sept-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 516: More OO Slot Operations","author":["Donal K. Fellows <[email protected]>"],"is-jest":false},
	"515":{"url":"./tip/515.md","vote-closes":"2018-09-26T12 00 00+0100","created":"7-Sept-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 515: Level Value Reform","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"514":{"url":"./tip/514.md","keywords":"Tcl","created":"20-Aug-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 514: Platform differences in handling int/wide","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"513":{"url":"./tip/513.md","keywords":"Tcl,data structure","created":"02-Aug-2017","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 513: Better support for 'agendas' as arrays, dictionaries or lists","author":["Florian Murr <[email protected]>"],"is-jest":false},
	"512":{"url":"./tip/512.md","keywords":"Tcl","created":"25-June-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 512: No stub for Tcl_SetExitProc()","author":["Jan Nijtmans <[email protected]>"],"is-jest":false},
	"511":{"url":"./tip/511.md","vote-closes":"2018-09-26T12 00 00+0100","keywords":"Tcl,threads","created":"14-June-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"In progress","type":"Project","title":"# TIP 511: Implement Tcl_AsyncMarkFromSignal()","author":["Christian Werner <[email protected]>"],"is-jest":false},
................................................................................
	"5":{"url":"./tip/5.md","created":"17-Oct-2000","post-history":"","state":"Final","vote":"Done","tcl-version":"8.4","type":"Project","title":"# TIP 5: Make TkClassProcs and TkSetClassProcs Public and Extensible","author":["Eric Melski <[email protected]>"],"is-jest":false},
	"4":{"url":"./tip/4.md","created":"26-Oct-2000","post-history":"","state":"Draft","vote":"Pending","type":"Informative","title":"# TIP 4: Tcl Release and Distribution Philosophy","discussions-to":"news comp.lang.tcl","author":["Brent Welch <[email protected]>","Donal K. Fellows <[email protected]k>","Larry W. Virden <[email protected]>","Larry W. Virden <[email protected]>"],"is-jest":false},
	"3":{"url":"./tip/3.md","created":"14-Sep-2000","post-history":"","state":"Accepted","vote":"Done","type":"Process","title":"# TIP 3: TIP Format","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>"],"is-jest":false},
	"2":{"url":"./tip/2.md","created":"12-Sep-2000","post-history":"","state":"Draft","vote":"Pending","type":"Process","title":"# TIP 2: TIP Guidelines","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>","Don Porter <[email protected]>","Mo DeJong <[email protected]>","Larry W. Virden <[email protected]>","Kevin Kenny <[email protected]>"],"is-jest":false},
	"1":{"url":"./tip/1.md","created":"14-Sep-2000","post-history":"","state":"Active","vote":"No voting","type":"Informational","title":"# TIP 1: TIP Index","author":["TIP Editor <[email protected]>"],"is-jest":false},
	"0":{"url":"./tip/0.md","created":"11-Dec-2000","post-history":"","state":"Final","vote":"Done","type":"Process","title":"# TIP 0: Tcl Core Team Basic Rules","author":["John Ousterhout <[email protected]>"],"is-jest":false},
	"@min": 0,
	"@max": 518
}, "@timestamp": 1537643890}

Changes to index.md.

115
116
117
118
119
120
121







122
123
124
125
126
127
128
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>








<tr class='invote'>
<td valign='top'><a href='./tip/517.md'>517</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Voting</td>
<td valign='top'># TIP 517: Add -activerelief Configuration Option to the menu widget</td>
</tr>






>
>
>
>
>
>
>







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>

<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/518.md'>518</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7.0</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 518: Virtual Event when Last Child is not Managed any more</td>
</tr>
<tr class='invote'>
<td valign='top'><a href='./tip/517.md'>517</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Voting</td>
<td valign='top'># TIP 517: Add -activerelief Configuration Option to the menu widget</td>
</tr>

Added tip/518.md.
























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# TIP 518: Virtual Event when Last Child is not Managed any more
	Author:         Harald Oehlmann <[email protected]>
	State:          Draft
	Type:           Project
	Vote:           Done
	Created:        22-Sep-2018
	Post-History:   
	Keywords:       Tk
	Tcl-Version:    8.7.0
-----
# Abstract

A **frame**-like widget has 1x1 required size if created.
If children are added by pack/grid and the last children is unpacked/grid, the frame-like widget does not return to the 1x1 required size.
Instead, it keeps the size of the last packed item.
It should automatically or under control resize to the initial requested size of 1x1.

# Rationale

A **frame** keeping a size without reason just feels like a bug and mostly leads to unwanted results.

Mostly, it looks just ugly, but there are critical use-cases, specially in scrolled frames.

When the BWidget autoscroll package is used, which displays scrollbars on demand, the scrollbars do not disappear if the contents is gone.
And there is nothing, a programmer can do, as the Configure event does not fire on the scrolled frame widget.

Another example is the scrolledwindow example by Emiliano in ticket 2863003fff <https://core.tcl.tk/tk/info/12006979562649c9> , where the solution 2 specific part may be removed \(or is ignored\).

A typical workaround is to configure the width/height manually after the last children was unmapped.
Unfortunately, this fact may not be determined for example by scrolling widgets etc. An eventual Configure binding is not firing.

Within this TIP, a new virtual event <<NoManagedChilds>> is fired to inform about no remaining childs.

# Example

Here is an example to ilustrate the issue.
It consisting of a simple scrolling megawidget.
The megawidget exposes a frame where a user may pack or grid other widgets and the scrollbar is adjusted following the changing content.
This works well when widgets are added or removed. Only removing the last client will not update the scrollbar. With the proposed patch applied, it will update the scrollbar also when the last user widget is removed.

Please paste the code below to a wish console or execute it.
On startup it shows on the console:
	requested frame height: 1

Then press the "\+" button to add a user widget. The console output is:
	+
	requested frame height: 100
Technically, the frame ".c.f.i1" was packed into the client frame ".c.f".
The client frame ".c.f" changes its requested size to hold the new child, which invokes the Convigure event and adjustes the scrolling region of the canvas.
The new scrolling region is shown graphically by the scrollbar.

Then press the "-" button to remove the user widget. The console output is:
	-
So, the child widget ".c.f.i1" is destroyed, but the frame ".c.f" does not rechange its requested size to 1x1 \(initial value\) but stays at 100x100 showing an empty plane.
The scrollbar is not updated and the megawidget has no possibility to adjust that \(expect additional user action to inform that the last child was removed\).

One may also try to add two childs and to remove them. It gets clear, that the widget is resized on removel if it is not the last widget.

With the proposed patch applied, an additional event is fired the removal of the last widget would restore the initial frame size of 1x1 which would invoke the Configure event and the scrollbar would be adjusted.

	wm geometry . 90x90
	# Button to add box on scrolling canvas
	set itemNo 0
	pack [button .b1 -command newBox -text +] -side left -fill y
	proc newBox {} {
	    puts +
	    incr ::itemNo
	    pack  [frame .c.f.i$::itemNo -borderwidth 4 -relief raised -bg red -width 100 -height 100] -side top
	}
	# Button to remove box on scrolling canvas
	pack [button .b2 -command removeBox -text -] -side left -fill y
	proc removeBox {} {
	    puts -
	    if {$::itemNo == 0} {return}
	    destroy .c.f.i$::itemNo
	    incr ::itemNo -1
	}
	
	# This is the scrolling megawidget which exposes frame .c.f for users to pack or grid clients
	# It has no knowledge, when the user adds or removes clients, e.g. when +/- is pressed
	pack [scrollbar .s -command {.c yview}] -side right -fill y
	pack [canvas .c -borderwidth 0 -yscrollcommand {.s set}] -side left -fill both
	frame .c.f
	.c create window 0 0 -window .c.f -anchor nw -tags win
	proc frameConfigure {} {
	    set y [winfo reqheight .c.f]
	    puts "requested frame height: $y"
	    .c configure -scrollregion [list 0 0 100 $y]
	}
	frameConfigure
	bind .c.f <Configure> frameConfigure

# Proposal

The proposal is to fire the new virtual event <<NoManagedChilds>> if the last children is unpacked/ungridded/destroyed.
A managing widget may bind to this event and do the resize of the widget or other appropriate action.

Here are additional lines for the example above.

	proc frameNoChild {} {
	    .c.f configure -height 1
	    .c.f configure -height 0
        }
	bind .c.f <<NoManagedChild>> frameNoChild

# Rejected Proposal

TIP 454 <https://core.tcl.tk/tips/doc/trunk/tip/454.md> has proposed to set the size of the widget automatically to 1x1 (the initial size if no widget packed/gridded).

Please read the discussion within the TIP which led to withdraw the proposal.

# Reference Implementation

Emiliano has provided a ticket 2863003fff <https://core.tcl.tk/tk/info/2863003fff>  with the implementation in branch bug-d6b95ce492 <https://core.tcl.tk/tk/timeline?r=bug-d6b95ce492&nd&c=2016-09-21+06%3A32%3A55&n=200>.

This solution is now continued with the tag "tip518-event-last-child-unmanaged".

Koen Dankart and Francois Vogel have worked on the solution of the similar tip474, which is available in branch bug-d6b95ce492-alt: <http://core.tcl.tk/tk/timeline?r=bug-d6b95ce492-alt&nd&c=2016-09-22+09%3A16%3A21&n=200> .
This information may eventually also be relevant.

# Copyright

This document has been placed in the public domain.