[PD-dev] pd patch window automatic scrollbars

Andre Schmidt andre at osku.de
Thu Apr 27 01:42:22 CEST 2006


hi list,

i finally got hacked a feature that i allways wanted:
automatic scrollbars :)

like, if the patch window is wider than the actual patch, dont show the
horizontal scrollbar, same for vertical. and of course show the
scrollbar(s) again, if patch bigger than window size...

i just started learning tcl/tk ~3 days ago, so this code may have
faults&co...

here we go (edit pd.tk)

add this: 
bind $name.c <Configure> { pdtk_canvas_scrollbars %W %w %h }
:some where (i have it by the other "bindings")

and add this:
proc pdtk_canvas_scrollbars {name x y} {
    set size [$name bbox all]
    set x2 [lindex $size 2]
    set y2 [lindex $size 3]
    set rootname [winfo parent $name]
    if {$x > $x2} {pack forget $rootname.scrollhort}
    if {$y > $y2} {pack forget $rootname.scrollvert}
    if {$x < $x2} {pack $rootname.scrollhort -side bottom -fill x
-before $rootname.c}
    if {$y < $y2} {pack $rootname.scrollvert -side right -fill y -before
$rootname.c}
}
:some where (i have it by the other "event bindings procedures")

thats it.

i dont know how i could use something like pd object [change] in those
pack if's... if needed ?

and having to use the same settings (-side, -fill) again doesnt sound
good neither....

well, atleast it seems to work :)

sleepy,
-andre

ps. sorry for line breaks, cant find the setting in my email client :/





More information about the Pd-dev mailing list