Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ttk::panedwindow minheight and sash

368 views
Skip to first unread message

Harald Oehlmann

unread,
May 18, 2016, 11:02:16 AM5/18/16
to
With ttk::panedwindow, I often have the issue, that the sash is at 0 or
maximum, and it is not obvious, that there is a panedwindow and one of
the managed windows are totally hidden.

I use ttk::labelframe as childs, so I want that at least the title of
the labelframe is visible.

On [http://wiki.tcl.tk/20058], there is a visible sash example under
"Create a Custom Sash Handle bar".

Unfortunately, this sash is not mapped, if the included windows require
all space.

Does anybody has a solution for:
a) setting/managing a minimum height of a window managed by a panedwindow
b) showing a sash which works (may be connected to issue a)

Thank you for any idea,
Harald

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Rich

unread,
May 18, 2016, 1:43:56 PM5/18/16
to
Harald Oehlmann <wort...@yahoo.de> wrote:
> Does anybody has a solution for:
> a) setting/managing a minimum height of a window managed by a panedwindow

This might work: setup an event binding on the <Configure> event for
the window you want to have a minimum width. Check its new width
within the event script. If its new width is too small, forcibly set
its width to the minimum value.

Brad Lanam

unread,
May 18, 2016, 1:52:36 PM5/18/16
to
I don't have a solution, was going to say what Rich said, but as an aside,
I have updated
http://wiki.tcl.tk/37973#pagetocfc771af9
with all the styling configuration options I could find.

harald

unread,
May 18, 2016, 2:35:16 PM5/18/16
to

Brad Lanam

unread,
May 18, 2016, 3:19:00 PM5/18/16
to
It seems like the initial sizing of the paned window is a bit difficult.

The code below will reset the sash position on release of the mouse button
if the sash is too far left.

#!/usr/bin/tclsh

package require Tk

proc dosash { w args } {
set sp [.p sashpos 0]
if { $sp < 20 } {
.p sashpos 0 30
}
}

proc conf { w args } {
}

proc out { f } {
.p forget $f
if { [llength [.p panes]] == 0 } {
wm withdraw .
}
update
wm manage $f
bind $f <ButtonRelease-1> [list in $f]
$f configure -background pink
}

proc in { f } {
wm forget $f
.p add $f
wm deiconify .
bind $f <ButtonRelease-1> [list out $f]
$f configure -background [string trim $f .]
}

ttk::style configure TPanedwindow \
-background blue
ttk::style configure Sash -sashthickness 20

ttk::panedwindow .p -orient horizontal -style TPanedwindow
pack .p -expand true -fill both
pack propagate .p false
frame .cyan -background cyan -height 200 -width 200
ttk::label .cyan.txt -text {This is frame one.}
pack .cyan.txt
frame .yellow -background yellow -height 200 -width 200
ttk::label .yellow.txt -text {This is frame two.}
pack .yellow.txt
.cyan configure -height 200 -width 200
.yellow configure -height 200 -width 200
.p add .cyan -weight 1
.p add .yellow -weight 1

bind .cyan <ButtonRelease-1> [list out .cyan]
bind .yellow <ButtonRelease-1> [list out .yellow]
bind .cyan <ButtonRelease-2> [list .cyan configure -width 420]
bind .yellow <ButtonRelease-2> [list .yellow configure -width 420]
bind .p <Configure> [list conf %W]
bind .p <ButtonRelease-1> [list dosash %W]
bind .cyan <Configure> [list conf %W]
bind .yellow <Configure> [list conf %W]

Harald Oehlmann

unread,
May 19, 2016, 3:03:30 AM5/19/16
to
Am 18.05.2016 um 21:18 schrieb Brad Lanam:
> It seems like the initial sizing of the paned window is a bit difficult.
>
> The code below will reset the sash position on release of the mouse button
> if the sash is too far left.

Dear Brad,

thank you for the script and action.
I am far from understanding the probably great solution.
So I have put it on the wiki including a reference to the style options.

My main issue is not that the user moves the sash to 0/max.
My main issue is, that the sash is positioned to 0/max by master window
resize or on startup or pane creation.

For me, the "-weight" option of the ttk::panedwindow does not work in
the sense, that sometimes, by resizing the window with the panedwindow,
one of the childs is kept to constant width and the other is resized
(with both -weight 1). So, one may disapear by resizing.
This is specially anoying, if the window is zoomed and returns to normal
state, and some panes just disapear.

Nice talking to you all... I will just live with the issues.

Anyway, thank you,

Christian Gollwitzer

unread,
May 19, 2016, 3:07:27 AM5/19/16
to
Am 19.05.16 um 09:03 schrieb Harald Oehlmann:
> My main issue is not that the user moves the sash to 0/max.
> My main issue is, that the sash is positioned to 0/max by master window
> resize or on startup or pane creation.

Maybe your child window does not request any size? What does

winfo reqheight $child
winfo reqwidth $child

return ?

Christian

mse...@gmail.com

unread,
May 19, 2016, 3:15:48 AM5/19/16
to
Hello Harald,

For my work I have implemented a system which works as follows.

I have two different pane contents one normal and one fixed with close state.
when the user drags the sash as soon as it is within n pixels of the edge it will snap to the edge and change to the closed state, clicking the button in the closed panel or dragging the sash away from the closed state will change back to the normal state and work as normal.

The panes can be created in the open or closed states.

This is similar to how older versions of outlook worked.

I will enquire at work to see if I can publish this code or parts of it, if not I will show you at the TCL conference in June if you are there.

Martyn

Brad Lanam

unread,
May 19, 2016, 3:31:44 AM5/19/16
to
On Thursday, May 19, 2016 at 12:03:30 AM UTC-7, Harald Oehlmann wrote:
> Am 18.05.2016 um 21:18 schrieb Brad Lanam:
> > It seems like the initial sizing of the paned window is a bit difficult.
>
> I am far from understanding the probably great solution.

Not so great. I know about as much about paned windows as you do at this
point. I am planning on using them in the future, so I would like to know
the answer to your question also -- how to size the paned window and its
children properly and how to deal with resizing. (and how to make a "grip"
for those themes without one).

> My main issue is, that the sash is positioned to 0/max by master window
> resize or on startup or pane creation.

I suspect a bind on the <Configure> of the paned window will be necessary,
then test the children to see what size they are, and adjust the sash
position to make them visible.

Brad Lanam

unread,
May 19, 2016, 4:10:50 PM5/19/16
to
You can put some frames next to the sash to make it more visible
and look more like something you can grab. With the proper use of
colors (which I'm not good at, but the below isn't terrible),
it could probably look pretty good.

For your sizing issues, I need some way to re-create the issue.


#!/usr/bin/tclsh

package require Tk

proc dosash { w args } {
set sp [.p sashpos 0]
if { $sp < 20 } {
.p sashpos 0 30
}
}

proc conf { w args } {
}

proc out { f } {
.p forget $f
if { [llength [.p panes]] == 0 } {
wm withdraw .
}
update
wm manage $f
bind $f <ButtonRelease-1> [list in $f]
$f configure -background pink
}

proc in { f } {
wm forget $f
.p add $f
wm deiconify .
bind $f <ButtonRelease-1> [list out $f]
$f configure -background [string trim $f .]
}

ttk::style configure TPanedwindow \
-background lightblue
ttk::style configure Sash -sashthickness 4

ttk::panedwindow .p -orient horizontal -style TPanedwindow
pack .p -expand true -fill both

frame .cyan -background cyan -height 200 -width 200
frame .cyan.sep -width 2 -relief ridge -background darkblue
pack .cyan.sep -side right -padx 0 -pady 0 -fill y -expand true -anchor e
ttk::label .cyan.txt -text {This is frame one.}
pack .cyan.txt

frame .yellow -background yellow -height 200 -width 200
frame .yellow.sep -width 2 -relief ridge -background darkblue
pack .yellow.sep -side left -padx 0 -pady 0 -fill y -expand true -anchor w
ttk::label .yellow.txt -text {This is frame two.}
pack .yellow.txt

Harald Oehlmann

unread,
May 23, 2016, 4:25:25 AM5/23/16
to
Hi Martyn,
thank you for the message. That sounds reasonable and understandable for
the user (which is my aim).
Unfortunately, I will not be in the Netherlands conference, private
other dates...

Thank you,
0 new messages