Custom sash handle for panedwindow

Difference between version 0 and 0 - Previous - Next
[APN] 2018-04-10 The following sample code for a custom sash handle was posted by 
debianuser on the Tclers chat. In particular it illustrates how
to pass on the mouse events to the underlying paned window handler.

======
package require Tk

panedwindow .pw -orient horizontal
listbox .pw.l1
listbox .pw.l2
.pw add .pw.l1 .pw.l2
pack .pw -fill both -expand true

image create photo img::grip -data R0lGODlhBAAvAPEAALetnfXz7wAAAAAAACH5BAEAAAIALAAAAAAEAC8AAAIjRBwZwmKomjsqyVdXw/XSvn1RCFlk5pUaw42saL5qip6gnBUAOw==
label .pw.grip -image img::grip -cursor sb_h_double_arrow ;# this cursor works!!!
place .pw.grip -relx 1 -rely .5 -anchor w -in .pw.l1

bind .pw.grip <Button-1> { event generate .pw <Button-1> -x [expr %x+[winfo x .pw.grip]] -y [expr %y+[winfo y .pw.grip]] }
bind .pw.grip <B1-Motion> { event generate .pw <B1-Motion> -x [expr %x+[winfo x .pw.grip]] -y [expr %y+[winfo y .pw.grip]] }

wm protocol . WM_DELETE_WINDOW exit
vwait forever
======

The above is for Tk's (not ttk) [panedwindow] widget but should work for 
ttk::panedwindows as well. Also see [ttk::panedwindow] for an alternative 
specific to it.


<<categories>>paned window|Widget|Tk