Tickit...Static(3pm)

πŸ’– Tickit::Widget::Static β€” bestie edition πŸ’–

okay so this is Tickit::Widget::Static, straight out of the User Contributed Perl Documentation section of the manual (perl 3pm, iykyk). it's giving "put some words on the screen and let them vibe there forever" ✨


🌸 NAME 🌸

Tickit::Widget::Static β€” a widget displaying static text πŸŽ€


✨ SYNOPSIS ✨

use Tickit;
use Tickit::Widget::Static;

my $hello = Tickit::Widget::Static->new(
   text   => "Hello, world",
   align  => "centre",
   valign => "middle",
);

Tickit->new( root => $hello )->run;

πŸ¦‹ DESCRIPTION πŸ¦‹

so this class hands you a widget that displays, like, one single piece of static text. that's it. that's the whole job. πŸ’…

the text can have more than one line, and you separate those lines with linefeed ("\n") characters. but bestie, listen β€” no other control sequences are allowed in the string. none. not even a little one. πŸ™ˆ


πŸŽ€ STYLE πŸŽ€

the default style pen is what's used as the widget pen. periodt.

lowkey important: the widget pen is mutable, and if you change it, it redraws immediately β€” slay. BUT πŸ’€ any changes you made will be lost if the widget style gets changed. so don't get attached.

🧚 CONSTRUCTOR 🧚

🌈 new

$static = Tickit::Widget::Static->new( %args );

constructs a brand new Tickit::Widget::Static object, no cap.

it takes these named arguments, on top of whatever the base Tickit::Widget constructor already takes:

  • text => STRING β€” the text to display ✨
  • align => FLOAT|STRING β€” optional. defaults to 0.0 if unspecified.
  • valign => FLOAT|STRING β€” optional. defaults to 0.0 if unspecified.
  • on_click => CODE β€” optional. defaults to undef if unspecified.

for more details, peek the accessors below πŸ‘‡


πŸ‘‘ ACCESSORS πŸ‘‘

πŸ’œ text

$text = $static->text;

πŸ’œ set_text

$static->set_text( $text );

accessor for the text property β€” aka the actual text on display in the widget. it's giving "what you see is what's set". 🫢

πŸ’œ align

πŸ’œ set_align

$align = $static->align;

$static->set_align( $align );

accessor for the horizontal alignment value. 🌈

hand it a value in the range from 0.0 to 1.0 and it aligns the text display within the window. if the window is bigger than the width of the text, it gets aligned according to this value β€” with 0.0 on the left, 1.0 on the right, and every other value somewhere inbetween. iconic behaviour honestly.

see also Tickit::WidgetRole::Alignable. πŸ¦‹


πŸ’– AUTHOR πŸ’–

Paul Evans <leonerd@leonerd.org.uk>


and that's the whole page, bestie!! πŸ’… this little writeup is perl v5.40.0, dated 2024-09-16, and it's the Tickit...Static(3pm) page β€” so like, go forth and align your static text, you absolute main character. mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from