Scrolled(3pm)

πŸ’– Scrolled β€” the Perl/Tk page, bestie edition πŸ’–

ok so this is Scrolled, from the Perl/Tk world (that's the Tk::Scrolled module, manual page Scrolled(3pm), and yeah it lives in the User Contributed Perl Documentation section πŸŽ€). Sit down, grab a strawberry πŸ“, we're gonna build a widget with a scrollbar attached to it.


✨ NAME ✨

Tk::Scrolled β€” create a widget with attached scrollbar(s) πŸ¦‹


✨ SYNOPSIS ✨

$whatever = $parent->Scrolled(Whatever ?,-scrollbars=>where?
?,...?);

that's it, that's the whole vibe πŸ’…


✨ DESCRIPTION ✨

so basically, Perl/Tk was getting a flood of ScrlWhatever widgets everywhere β€” like, every single widget class was out here getting its own scrolled twin β€” and the maintainers said "no more, we're ending this" 😭. Enter the special constructor: Scrolled πŸ‘‘

Scrolled creates a widget of the given Class Whatever with attached scrollbar(s). One constructor, all the classes, no cap. ✨


✨ OPTIONS ✨

ok so every option besides -scrollbars (which we're about to explain, don't worry bestie) gets passed straight through to the Whatever widget's own constructor. So they're not Scrolled's options, they're the other widget's options, we're just holding them for a sec. 🫢

  • -scrollbars β€” expects as its argument the position</> where the scrollbars should be created: w, e or n, s β€” or a combination of them. And here's the fun part: if one or both of those positions gets prefixed with o, the scrollbar will only show up if there's a 'real' need to scroll. so it's shy, it only appears when it's actually needed 🧚 iykyk

✨ ADVERTISED SUBWIDGETS ✨

go read "Subwidget" in Tk::mega to find out how to use advertised widgets, that's the homework πŸ“š now here's the roster:

  • scrolled β€” the scrolled widget. the main character πŸ‘‘
  • widget β€” same as scrolled above. widget is the kind of widget passed to scrolled as first argument, in all lowercase. so if you passed Whatever, you get whatever. lowercase era πŸ’œ
  • xscrollbar β€” the Scrollbar widget used for horizontal scrolling (if it exists)
  • yscrollbar β€” the Scrollbar widget used for vertical scrolling (if it exists)
  • corner β€” a frame in the corner between the vertical and horizontal scrolbar
πŸ‘€ yes, "scrolbar" is spelled like that up there in the corner one. we keep it exactly as it is, periodt.

✨ BUGS ✨

ok this part is important, listen up πŸ™ˆ

If a widget does not support -{x,y}scrollcommand options, Scrolled does not complain if the specified widget class does not support them. Like, for example:

$parent->Scrolled('Button', ...)

and also β€” you do not get an error message or a warning when you try to configure scrollbars after the widget has already been constructed:

$ascrolled->configure(-scrollbars => 'e');

so yeah, it'll just sit there silently and not tell you. not great, not terrible, just how it is πŸ’€


✨ SEE ALSO ✨

  • Tk::Scrollbar πŸŽ€

✨ KEYWORDS ✨

scrolled, scrollbar πŸ”₯


ok that's the whole page bestie, you're officially educated πŸ’…βœ¨

this was perl v5.40.1, dated 2025-04-13 β€” so yeah, from the Scrolled(3pm) page, love u, bye 🫢🌸

πŸ“¦ where this page comes from