Limiting scroll bar length Limiting scroll bar length tkinter tkinter

Limiting scroll bar length


The trick is to place the widgets with the grid geometry manager, which essentially creates an (uneven-sized) 4x4 grid with the text widget at "North-West", the vertical scrollbar at "North-East", the horizontal scrollbar at "South-West", and the empty square at "South-East". There is a relevant example on the man page.

I think I'm allowed to quote the man page example as fair use (noting that it's Copyright © 1995-1997 Roger E. Critchlow Jr. Copyright © 1996 Sun Microsystems, Inc.).

# Make the widgetstoplevel .ttext .t.txt -wrap none -xscroll {.t.h set} -yscroll {.t.v set}scrollbar .t.v -orient vertical   -command {.t.txt yview}scrollbar .t.h -orient horizontal -command {.t.txt xview}# Lay them outgrid .t.txt .t.v -sticky nsewgrid .t.h        -sticky nsew# Tell the text widget to take all the extra roomgrid rowconfigure    .t .t.txt -weight 1grid columnconfigure .t .t.txt -weight 1

You'll have translate to Perl-Tk yourself, however. There is some Perl-Tk-related discussion of grid (though not specifically about scrollbars) here at TkDocs that might get you started. The "Learning Perl/Tk" sample chapter Geometry Management also discusses grid.

Oh! You wanted a resizing control in the fourth square as well. In Tcl/T(t)k, it's called a ttk::sizegrip and it's documented here. I've never used it myself (as there are other ways to resize the window) and don't know if it's in Perl-Tk. If it's not, there is a wiki page discussing how to fake it (again, I've never tried that code myself).