I find moving panedwindows very frustrating.
My idea was to
1. drag sashes and save their positions so they could be re-applied
upon application restart
2. adjust column widths after they have been created, as needed.
For example, to adjust according to new content.
Mind you, the manual says this:
"Unlike slave windows managed by e.g. pack or grid, the panes
managed by a panedwindow do not change width or height to accomodate
changes in the requested widths or heights of the panes, once these
have become mapped."
I don't mind that they won't do that automatically. But they won't
let me do it programatically either.
Or will they?
First, something odd that I noticed. I am once again sharing some code
I shared yesterday:
-----------------------------
panedwindow $::Widgets_unipane.singleViewModeFileListPane -orient horizontal \
-background #FFFFFF -borderwidth 0 \
-cursor arrow -sashcursor sb_h_double_arrow -sashwidth 1 -showhandle 0 -sashrelief flat -handlepad 1
pack $::Widgets_unipane.singleViewModeFileListPane -fill both -expand 1
array set widths {filename 100 size 100 date 160 permission 120 owner 120} set ::parent $::Widgets_unipane.singleViewModeFileListPane
foreach columnname $::CustomVars_FileListColumns {
set columnname [string tolower $columnname]
w.add frame [set columnname]frame "wi $widths($columnname) cu arrow fi both ex 1"
w.add button [set columnname]frame.button \
"tx [string totitle $columnname] fo {Arial 12} -bd 0 cu arrow \
bg #FFFFFF fg #BFBFBF highlightthickness 0 fi x ex 0 si top"
w.add text [set columnname]frame.box \
"fo {Arial 16} bg #FFFFFF fg #000000 bd 0 pd {0 0} sp1 1 sp2 1 sp3 1 \
wr none tf 0 es 1 un 0 st normal sg true cu arrow ys p.Utils.filelist.yset \
fi both ex 1 si left"
$::Widgets_unipane.singleViewModeFileListPane add $::Widgets_unipane.singleViewModeFileListPane.[set columnname]frame
$::Widgets_unipane.singleViewModeFileListPane.[set columnname]frame.box configure -relief flat -selectborderwidth 0 -insertborderwidth 0 -highlightthickness 1
$::Widgets_unipane.singleViewModeFileListPane paneconfigure $::Widgets_unipane.singleViewModeFileListPane.[set columnname]frame -stretch first -width $widths($columnname)
}
-----------------------------
The odd thing is that I set the width of each column on two points of
the code with $widths($columnname). Either one alone won't do it. Both
are required. Which is weird. I wonder how much of that is by design.
Then I try to restore the widths after everything is already running.
For a simple test, an arbitrary number will do. So let it be 300:
$::Widgets_unipane.singleViewModeFileListPane.sizeframe configure -width 300 $::Widgets_unipane.singleViewModeFileListPane paneconfigure $::Widgets_unipane.singleViewModeFileListPane.sizeframe -stretch first -width 300
But that has absolutely no effect. Nothing happens.
Not being able to set an arbitrary width because the whole thing is effectively frozen is frustrating enough. But it gets worse.
set ::FlowControl_DebugText [$::Widgets_unipane.singleViewModeFileListPane sash coord 0]
That gives me 100 0.
Now, what is 100 and what is 0? Relative to what? I don't see it in the manual. Those can't be absolute coordinates.
Well, that column is indeed configured to be 100 pixels wide so maybe
that is that? So let's increase it to 200.
$::Widgets_unipane.singleViewModeFileListPane sash place 0 200 0
The column disappears. I think know why.
So let's try a much smaller number:
$::Widgets_unipane.singleViewModeFileListPane sash place 0 50 0
Ah, the sash has retreated (moved towards left).
Again:
$::Widgets_unipane.singleViewModeFileListPane sash place 0 10 0
It has retreated even more.
$::Widgets_unipane.singleViewModeFileListPane sash place 0 0 0
Now I expected the sash to retreat just a little bit more, but instead
of that the column to the left of "size" has disappeared completely
which is surprising because the disappearing column was really wide
(it was the first one so it had the "stretch" privilege) so there was
plenty, really plenty of room for the sash to retreat just a little
more and hit what I assumed would be "0".
Now I begin to see or assume that "0" is some kind of black hole
that will swallow widgets whole! Don't go near it!
Let's try another approach:
$::Widgets_unipane.singleViewModeFileListPane sash mark 0 100 0 $::Widgets_unipane.singleViewModeFileListPane sash dragto 0 10 0
Now the sash retreats quite a bit, so I guess it retreated 90 pixels
because 100 - 90 = 10. But I have to be very careful never to subtract
the whole mark index because of the black hole:
$::Widgets_unipane.singleViewModeFileListPane sash mark 0 100 0 $::Widgets_unipane.singleViewModeFileListPane sash dragto 0 0 0
Again, that causes the column to the left of the shash to disappear completely.
So MAYBE I still can achieve my 2 original goals, but they (especially
goal #1) will require quite a bit of math and pitfall dodging.
Is it all really supposed to be that hard or am I doing something very
wrong again?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 464 |
Nodes: | 16 (2 / 14) |
Uptime: | 161:12:07 |
Calls: | 9,385 |
Calls today: | 5 |
Files: | 13,561 |
Messages: | 6,096,399 |