Tk Source Code

View Ticket
Login
2017-08-31
18:44 Ticket [84f58fdf19] Panedwindow handle width, color and relief status still Open with 3 other changes artifact: e484732d5d user: fvogel
2017-01-15
03:24 Ticket [84f58fdf19]: 3 changes artifact: 273bc91411 user: anonymous
2016-12-18
22:42 Ticket [84f58fdf19]: 3 changes artifact: 7a1da67a61 user: fvogel
22:13 Ticket [84f58fdf19]: 3 changes artifact: 1490c14ed7 user: anonymous
2016-12-12
07:36 Ticket [84f58fdf19]: 3 changes artifact: d2441c096e user: fvogel
02:17 Ticket [84f58fdf19]: 3 changes artifact: 4a45ce01ef user: anonymous
2016-12-11
15:56 Ticket [84f58fdf19]: 3 changes artifact: 11f8637a5f user: fvogel
15:15 Ticket [84f58fdf19]: 3 changes artifact: 22a408f46c user: anonymous
08:33 Ticket [84f58fdf19]: 3 changes artifact: 164c8e9882 user: fvogel
07:44 Ticket [84f58fdf19]: 3 changes artifact: 8b2e364313 user: fvogel
03:44 Ticket [84f58fdf19]: 3 changes artifact: 1660020d8f user: anonymous
2016-12-08
22:03 Ticket [84f58fdf19]: 3 changes artifact: dde0e48579 user: fvogel
21:42 New ticket [84f58fdf19]. artifact: a3139dac01 user: anonymous

Ticket UUID: 84f58fdf191834f39505290118499ddac44e98d5
Title: Panedwindow handle width, color and relief
Type: RFE Version: 8.6
Submitter: anonymous Created on: 2016-12-08 21:42:53
Subsystem: 21. [panedwindow] Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2017-08-31 18:44:09
Resolution: None Closed By: nobody
    Closed on:
Description:

To add the possibility to customize the widh, color and relief of Tk panedwindow handle, improve much more the control over the look and feel and at the same time maybe its not too difficult to implement with the current code. Tk panedwindow is very powerful and has much more methods (for example for moving the sash) than Ttk panedwindow and provide also another extra behaviour that doesn't provide ttk panedwindow like for exmaple to change panes proportionaly to the current ratio. For this reason, I think that this improvement is important.

User Comments: anonymous added on 2017-01-15 03:24:09:
Another interesting possibility is to use an image as a handle

fvogel added on 2016-12-18 22:42:00:
IMO, for backwards compatibility reasons:

- Whenever (at widget creation time, or later through the configure command) -handlesize is given simultaneously with -handlewidth and/or -handleheight, then it must take precedence and -handlewidth and -handleheight should be silently ignored.

- Otherwise, when -handlesize, -handlewidth, -handleheight are given in commands such that the previous rule does not apply (for instance through successive configure commands of the panedwindow widget), then these options are applied in the given order.

anonymous added on 2016-12-18 22:13:34:
I think that the -handlesize optinon shouldnt be deleted for backwards compatibility. What do you think about the name of these options: 
<pre>
   -handlewidth
   -handleheight
   -handlecolour
   -handlerelief
</pre>

There is 2 possibilities for combining -handlesize with -handlewidth, and -handleheight:
<ul>
<li>Its not possible to provide -handlesize and at the same time provide -handlewidth or -handleheight. This situation should raise an error. </li>
<li>Its possible to combine -handlesize option with -handlewidth or -handleheight. -handlesize provides a value for the width and height of the handle. If -handlewidth and -handleheight are present, then these values are overriden.
</li>
</ul>

Which behaviour do you think that its better?

fvogel added on 2016-12-12 07:36:09:
The easiest is probably to start from, say, TIP #443, download the "Source format" (there is a link at the bottom of the TIP), and edit this. Then send it to dkf by email.

anonymous added on 2016-12-12 02:17:54:
I will try to write a TIP next weekend. I dont know very well how to do that but I will try.

fvogel added on 2016-12-11 15:56:27:
IIUC you're using the place geometry manager to absolutely position a frame having the required charactristics. Then you need to maintain the coordinates through a series of bindings. Well, this is a bit long code to achieve control of the handle of a panedwindow.

Given that it is not straightforward at script level, it should probably be possible to have new panedwindow handle options accepted through a TIP.

So yes, please go ahead and submit a TIP. I will sponsor it and do the corresponding C implementation.

anonymous added on 2016-12-11 15:15:38:
I understand the situation. There is now a size option for handle. But anyway its always better to guive more flexibility. Also it was possible to create panedwindow using Tcl before 2001:
http://www.tcl.tk/cgi-bin/tct/tip/41.html

This is the code_

namespace eval beautiful_handle {
    array set handle_data ""
}

proc beautiful_handle::create_handle {master sash_index args} {
    variable handle_data

    set handle [frame $master.[info cmdcount] {*}$args]

    set handle_data($handle:sash_index) $sash_index

    set handle_data($handle:center_x) [expr {int([$handle cget -width]/2)}]
    set handle_data($handle:center_y) [expr {int([$handle cget -height]/2)}]

    bind $handle <Button-1> [list [namespace current]::_initiate_motion $handle %x %y]
    bind $handle <ButtonRelease-1> [list [namespace current]::_release_dragging $handle]
    
    return $handle
}

proc beautiful_handle::sash_index {handle} {
    return $handle_data($handle:sash_index)
}

proc beautiful_handle::_release_dragging {handle} {
    bind $handle <Motion> ""
}

proc beautiful_handle::_initiate_motion {handle x y} {
    variable handle_data

    set handle_data($handle:dx) $x
    set handle_data($handle:dy) $y

    if {[[winfo parent $handle] cget -orient] eq "horizontal"} {
        bind $handle <Motion> [list [namespace current]::_on_horizontal_dragging $handle %X %Y]
    } else {
        bind $handle <Motion> [list [namespace current]::_on_vertical_dragging $handle %X %Y]
    }
}

proc beautiful_handle::_on_vertical_dragging {handle x_root y_root} {
    variable handle_data

    set parent [winfo parent $handle]

    set y [expr $y_root - [winfo rooty $parent] - $handle_data($handle:dy)]
    
    set center_y $handle_data($handle:center_y)
    if {$y < $center_y} {
        set y $center_y
    }

    place configure $handle -y $y
    $parent sash place $handle_data($handle:sash_index) 1 $y
}

proc beautiful_handle::_on_horizontal_dragging {handle x_root y_root} {
    variable handle_data

    set parent [winfo parent $handle]

    set x [expr $x_root - [winfo rootx $parent] - $handle_data($handle:dx)]
    
    set center_x $handle_data($handle:center_x)
    if {$x < $center_x} {
        set x $center_x
    }

    place configure $handle -y $y
    $parent sash place $handle_data($handle:sash_index) 1 $y
}

proc beautiful_handle::_on_change_hpane_size {handle} {
    variable handle_data

    set parent [winfo parent $handle]

    set sash_index $handle_data($handle:sash_index)
    set x [lindex [$parent sash coord $sash_index] 0]
    place configure $handle -x $x
}

proc beautiful_handle::_on_change_vpane_size {handle} {
    variable handle_data
    
    set parent [winfo parent $handle]

    set sash_index $handle_data($handle:sash_index)
    set y [lindex [$parent sash coord $sash_index] 1]
    place configure $handle -y $y
}

proc beautiful_handle::add_to {panedwindow {color gray} {size 60}} {
    $panedwindow configure -showhandle 0

    set orient [$panedwindow cget -orient]

    if {$orient eq "vertical"} {
        set width $size
        set height [expr 2* [$panedwindow cget -sashpad]]
        set cursor sb_v_double_arrow

        set configure_command beautiful_handle::_on_change_vpane_size
    } else {
        set width [expr 2* [$panedwindow cget -sashpad]]
        set height $size
        
        set cursor sb_h_double_arrow
        
        set configure_command beautiful_handle::_on_change_hpane_size

    }
    
    set list_of_panes [$panedwindow panes]
    
    set len [expr [llength $list_of_panes] -1]
    for {set i 0} {$i < $len} {incr i} {
        
        set handle [create_handle $panedwindow $i -bg $color -height $height -width $width -cursor $cursor]
        place $handle -relx 0.5 -anchor c

        bind [lindex $list_of_panes $i] <Configure> [list $configure_command $handle]
        bind [lindex $list_of_panes [expr $i +1]] <Configure> [list $configure_command $handle]
    }
}

set panedwindow [panedwindow .panedwindow -orient vertical -sashpad 3]
pack $panedwindow -fill both -expand 1


foreach color {red blue green} {
    set frame [frame $panedwindow.${color}_frame -width 200 -height 200 -bg $color]
    $panedwindow add $frame -stretch always
}

beautiful_handle::add_to $panedwindow

fvogel added on 2016-12-11 07:44:57:
Interesting. This means that a pure Tcl/Tk solution exists to do what you want.

If such a script level solution exists, then it is likely a TIP is not needed in fact. Or rather that a TIP is still needed to implement new panedwindow options, but this TIP would probably be rejected if a few lines of Tcl/Tk would allow to get the same result.

So yes, please show the Tcl/Tk script code that you used to achieve what you want (sorry I don't really read Tkinter). It would help deciding whether writing a TIP is worth the effort or not.

Regarding the C implementation I could take this in charge, no problem.

anonymous added on 2016-12-11 03:44:10:
Hi, many thanks for your answer. I can contribute and write a TIP but for me its very difficult to contribute writting C code. 

I made what I want using Tkinter. This is my recipe in activestate:
   http://code.activestate.com/recipes/580728-tkinter-beautiful-handler-for-pannedwindow-similar/

If you want, I can translate the recipe to Tcl.

Then, Do I writte a TIP?

fvogel added on 2016-12-08 22:03:21:

The Tk panedwindow already has an option to customize the handle width, which is -handlesize. As mentioned in the manual, handles are (currently) always drawn as squares. Do you request this to be changed, with e.g. new options such as -handlewidth and -handleheight? So what should we do with -handlesize now? Deprecate it? This has to be made clear.

Regarding the other two options you want (-handlecolor and -handlerelief I guess), I think I see what you mean.

Well, the process for such changes is to write a TIP. You can start here, generally speaking, and certainly take TIP #443 as a more specific example. Once you draft it we can help.