Label(3pm)
โจ Label(3pm) โจ
okay bestie, so this is the manual for Tk::Label โ it lives in the Perl docs under "User Contributed Perl Documentation" and it's literally the whole vibe of "how do I put a little piece of text (or a pic) on the screen and just... leave it there". Sit down, grab a boba, we're doing this ๐ซถ
๐ธ NAME ๐ธ
Tk::Label โ Create and manipulate Label widgets ๐
๐ SYNOPSIS ๐
$label = $parent->Label(?options?);
โจ STANDARD OPTIONS โจ
these are the inherited glow-ups, the ones every well-behaved widget gets:
-activebackground-activeforeground-anchor-background-bitmap-borderwidth-compound-cursor-disabledforeground-font-foreground-highlightbackground-highlightcolor-highlightthickness-image-justify-padx-pady-relief-takefocus-text-textvariable-underline-wraplength
See Tk::options for details of the standard options. โ that's the lore drop for all the deets, go read it, it's giving encyclopedia ๐
๐ WIDGET-SPECIFIC OPTIONS ๐
these three are the label's own signature moves, the ones that make it it:
- Name:
heightClass:HeightSwitch:-height
Specifies a desired height for the label. If an image or bitmap is being displayed in the label then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in lines of text. If this option isn't specified, the label's desired height is computed from the size of the image or bitmap or text being displayed in it. no cap, it just does the math for you ๐งฎ
- Name:
stateClass:StateSwitch:-state
Specifies one of three states for the label: normal, active, or disabled. In normal state the label is displayed using the foreground and background options. In active state the label is displayed using the activeForeground and activeBackground options. In the disabled state the disabledForeground and background options determine how the button is displayed. (yes bestie, it says "button", that's literally what the page says, we don't question the ancestors ๐)
- Name:
widthClass:WidthSwitch:-width
Specifies a desired width for the label. If an image or bitmap is being displayed in the label then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in characters. If this option isn't specified, the label's desired width is computed from the size of the image or bitmap or text being displayed in it. again, auto-sized, we love a self-sufficient icon ๐
๐ฆ DESCRIPTION ๐ฆ
The Label method creates a new window (given by the $widget argument) and makes it into a label widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the label such as its colors, font, text, and initial relief. The label command returns its $widget argument. At the time this command is invoked, there must not exist a window named $widget, but $widget's parent must exist.
โ ๏ธ okay this part is important: if a window called $widget is already out there, that's a problem. and if the parent doesn't exist? also a problem. know your family tree before you spawn ๐ซถ
A label is a widget that displays a textual string, bitmap or image. If text is displayed, it must all be in a single font, but it can occupy multiple lines on the screen (if it contains newlines or if wrapping occurs because of the wrapLength option) and one of the characters may optionally be underlined using the underline option. The label can be manipulated in a few simple ways, such as changing its relief or text, using the commands described below.
so like โ one font, but as many lines as you want. the range?? truly unmatched ๐
๐ WIDGET METHODS ๐
The Label method creates a widget object. This object supports the configure and cget methods described in Tk::options which can be used to enquire and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class.
tl;dr: configure to change stuff, cget to peek at stuff, and everything from Tk::Widget comes free with purchase. it's giving nepo baby but in a good way ๐
๐ฅ BINDINGS ๐ฅ
When a new label is created, it has no default event bindings: labels are not intended to be interactive.
๐ bestie, do NOT click on the label expecting a reaction. it does not want that. it is decorative. it is furniture. it is art. it is not a button. periodt.
๐ KEYWORDS ๐
- label
- widget
and that's the whole page, bestie!! this doc shipped with perl v5.40.1 and was dated 2025-04-13 โ so go forth, make labels, stay iconic, and remember: labels don't do events, they just look pretty. mwah ๐
๐ฆ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms