• I find moving panedwindows very frustrating

    From Luc@21:1/5 to All on Mon Dec 18 16:56:31 2023
    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?


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Dec 18 22:09:05 2023
    Am 18.12.2023 um 20:56 schrieb Luc:
    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?



    Hi Luc,

    here is my sequence to create a ttk::panedwindow with two saved sash
    positions:

    pack [set WiPath(WiPaned) [ttk::panedwindow $WiPath(FrTop).p\
    -orient vertical]\
    ] -fill both -expand true -side top
    # Add 3 Panes
    foreach Index {1 2 3}\
    Weight {0 0 1}\
    {
    set WiPath(FrP$Index) [ttk::frame $WiPath(WiPaned).p$Index]
    $WiPath(WiPaned) add $WiPath(FrP$Index) -weight $Weight
    }
    # Init sash positions
    foreach Sash {0 1} {
    set Pos [lindex $State(SashPosY) $Sash]
    if {[string is entier -strict $Pos]} {
    $WiPath(WiPaned) sashpos $Sash $Pos
    }
    }


    And here is how it is saved on program end:

    foreach Sash {0 1} {
    lappend State(SashPosY) [$WiPath(WiPaned) sashpos $Sash]
    }

    Hope this helps,
    Harald

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