Bwidget Source Code
View Ticket
Not logged in
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.
Ticket UUID: 72a5727d1b7fb76b32cea032eb7d4bf7c6fa28b
Title: ScrollableFrame changes width upon unmap and map events
Type: Bug Version: 1.9.10
Submitter: oehhar Created on: 2016-10-13 14:31:46
Subsystem: bwidget 1.x Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2016-11-03 00:02:18
Resolution: Fixed Closed By: oehhar
    Closed on: 2016-11-03 00:02:18
Description:

Follwing ticket copied from tcllib tracker: http://core.tcl.tk/tcllib/tktview/9d21e52e39c37d9521e8d34da3b301219b8f909c

As stated in the title, the ScrollableFrame changes width upon unmap and map events.

See: https://groups.google.com/forum/#!topic/comp.lang.tcl/Q5prg9lsOYc

I have found the bug and solved it. Here are the original and modified procedures:

proc ScrollableFrame::_frameConfigure {canvas {unmap 0}} {
    # This ensures that we don't get funny scrollability in the frame
    # when it is smaller than the canvas space
    # use [winfo] to get height & width of frame

    # [winfo] doesn't work for unmapped frame
    set frameh [expr {$unmap ? 0 : [winfo height $canvas.frame]}]
    set framew [expr {$unmap ? 0 : [winfo width $canvas.frame]}]

    set height [_max $frameh [winfo height $canvas]]
    set width [_max $framew [winfo width $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}

This is the modified above procedure.

proc ScrollableFrame::_frameConfigure {canvas {unmap 0}} {
    # This ensures that we don't get funny scrollability in the frame
    # when it is smaller than the canvas space
    # use [winfo] to get height & width of frame

    # [winfo] doesn't work for unmapped frame
    if {$unmap} {  return  }

    set frameh [winfo height $canvas.frame]
    set framew [winfo width $canvas.frame]

    set height [_max $frameh [winfo height $canvas]]
    set width [_max $framew [winfo width $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}

User Comments: oehhar added on 2016-11-03 00:02:18:

The following communication with Eric caused commit [6d0524a1f8]:

Me:

just a short question. The "magic" scrolledview pussels me, as you may have noticed on the core list ;-)

Now I had a bug in bwidget: http://core.tcl.tk/bwidget/info/72a5727d1b7fb76b which basically removes the "Unmap" event from the scrolledview. I checked it, it does help to keep the size on minimize and restore.

So my question: what is the purpose of the initial "Unmap" binding in the scrolledview frame ?

Eric:

I have looked at the old and new code, and don't find anything wrong. But I don't really understand the original problem, because _frameConfigure only deals with -scrollregion, and not on widget size. The impact is probably on the ScrolledWindow which hide / show the scrollbars?

About the purpose of <Unmap>, I can't really tell, it has been introduced by you and Koen :-)

IMO, the best is to do nothing if the widget is unmapped, as proposed by the fix, but using directly [winfo ismapped] in _frameConfigure:

if {![winfo ismapped $canvas.frame]} {
   return
}
Then keeping <Map> event to call _frameConfigure again is OK.


oehhar added on 2016-10-31 15:13:42:

Committed by checkin [06d203dbdd]. Thank you !

I have a strange feeling with this modification. It is Erics code and he normally know what he does. I don't ;-)


oehhar added on 2016-10-13 14:39:08:

Here is the original post:

I have the problem, that a toplevel window increases the width after it is minimized and then restored by user click on the task bar icon of the window, if before that the contained panedwindow is resized.

Here is a video demonstration:

http://expirebox.com/download/495a00e6ab3add183713f744cc9c07db.html

Here is the code:

package require BWidget

pack [ttk::panedwindow .pw -orient horizontal] -side top -expand 1 -fill both
ScrolledWindow .pw.sw
ttk::labelframe .pw.props -text {Second frame}
.pw add .pw.sw -weight 1
.pw add .pw.props -weight 1
set sf [ScrollableFrame .pw.sw.sf]
.pw.sw setwidget $sf
pack [ttk::labelframe .pw.sw.sf.lf -text {First frame}] -side top -expand 1 -fill both

grid [text .pw.sw.sf.lf.t -bd 0 -height 2 -cursor arrow -pady 1] -sticky ew
grid [ttk::label .pw.props.l -text {Some text}] -sticky ew

How to avoid this weird behavior? I'm inclined to think that this is a bug in Tk or BWidget's panedwindow.

Thanks Alexandru