Gtk2::Label(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Gtk2::Label β€” bestie, it's a wrapper for GtkLabel. That's the whole vibe. It's the thing that puts words on your screen, and it does it with main character energy. πŸŽ€


πŸ¦‹ HIERARCHY πŸ¦‹

Okay so this is the family tree, and yes she comes from a long line of iconic ancestors:

  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::Misc
                      +----Gtk2::Label

🌈 INTERFACES 🌈

She also implements these, because she contains multitudes:

  Glib::Object::_Unregistered::AtkImplementorIface
  Gtk2::Buildable

✨ METHODS ✨

  • widget = Gtk2::Label->new ($str=undef) β€” makes you a fresh label. πŸ’…
    • $str (string or undef)
  • widget = Gtk2::Label->new_with_mnemonic ($str) β€” same deal but with mnemonic powers unlocked.
    • $str (string)
  • double = $label->get_angle β€” grabs the rotation angle.
    • Since: gtk+ 2.6
  • $label->set_angle ($angle) β€” sets the rotation angle, go off.
    • $angle (double)
    • Since: gtk+ 2.6
  • attrlist = $label->get_attributes β€” gets the Pango::AttrList of style attributes.
  • $label->set_attributes ($attrs) β€” sets the style attributes.
    • $attrs (Pango::AttrList)
  • string = $label->get_current_uri β€” gets the URI currently under the cursor, lowkey iconic.
    • Since: gtk+ 2.18
  • ellipsizemode = $label->get_ellipsize β€” how is she cutting off the text when there's no room?
    • Since: gtk+ 2.6
  • $label->set_ellipsize ($mode) β€” tell her where to trim.
    • $mode (Pango::EllipsizeMode)
    • Since: gtk+ 2.6
  • justification = $label->get_justify β€” the alignment of the lines relative to each other.
  • $label->set_justify ($jtype) β€” set that alignment.
    • $jtype (Gtk2::Justification)
  • string = $label->get_label β€” gets the text.
  • $label->set_label ($str) β€” sets the text, fr fr.
    • $str (string)
  • layout = $label->get_layout β€” hands you the Pango::Layout.
  • (x, y) = $label->get_layout_offsets β€” the layout's offsets, as a cute lil pair.
  • boolean = $label->get_line_wrap β€” is line wrap on or nah?
  • wrapmode = $label->get_line_wrap_mode β€” which wrap mode tho.
    • Since: gtk+ 2.9
  • $label->set_line_wrap_mode ($wrap_mode) β€” set the wrap mode.
    • $wrap_mode (Pango::WrapMode)
    • Since: gtk+ 2.9
  • $label->set_line_wrap ($wrap) β€” turn line wrapping on or off.
    • $wrap (boolean)
  • $label->set_markup ($str) β€” set the text as markup.
    • $str (string)
  • $label->set_markup_with_mnemonic ($str) β€” markup and mnemonic, the combo meal.
    • $str (string)
  • integer = $label->get_max_width_chars β€” the max width, counted in characters.
    • Since: gtk+ 2.6
  • $label->set_max_width_chars ($n_chars) β€” set that max width.
    • $n_chars (integer)
    • Since: gtk+ 2.6
  • integer = $label->get_mnemonic_keyval β€” the mnemonic accelerator keyval, as an integer.
  • widget or undef = $label->get_mnemonic_widget β€” the widget tied to the mnemonic, or undef if there isn't one.
  • $label->set_mnemonic_widget ($widget) β€” assign the mnemonic widget.
    • $widget (Gtk2::Widget or undef)
  • $label->set_pattern ($pattern) β€” sets the underline pattern.
    • $pattern (string)
  • $label->select_region ($start_offset=-1, $end_offset=-1) β€” selects a chunk of the text.
    • $start_offset (integer)
    • $end_offset (integer)
  • boolean = $label->get_selectable β€” can you select the text with your mouse? πŸ‘€
  • $label->set_selectable ($setting) β€” toggle selectability.
    • $setting (boolean)
  • (start, end) = $label->get_selection_bounds β€” returns integers, start and end. Simple as that.
  • boolean = $label->get_single_line_mode β€” single line mode status check.
    • Since: gtk+ 2.6
  • $label->set_single_line_mode ($single_line_mode) β€” flip single line mode.
    • $single_line_mode (boolean)
    • Since: gtk+ 2.6
  • string or undef = $label->get_text β€” grabs the text, might be undef, no cap.
  • $label->set_text ($str) β€” sets the text.
    • $str (string or undef)
  • $label->set_text_with_mnemonic ($str) β€” text + mnemonic, together at last.
    • $str (string)
  • boolean = $label->get_track_visited_links β€” are we tracking visited links or not?
    • Since: gtk+ 2.18
  • $label->set_track_visited_links ($track_links) β€” toggle that tracking.
    • $track_links (boolean)
    • Since: gtk+ 2.18
  • boolean = $label->get_use_markup β€” is the text being read as XML markup?
  • $label->set_use_markup ($setting) β€” toggle markup mode.
    • $setting (boolean)
  • boolean = $label->get_use_underline β€” is an underline being used to signal the next character as a mnemonic accelerator?
  • $label->set_use_underline ($setting) β€” toggle that underline behaviour.
    • $setting (boolean)
  • integer = $label->get_width_chars β€” the desired width, in characters.
    • Since: gtk+ 2.6
  • $label->set_width_chars ($n_chars) β€” set the desired width.
    • $n_chars (integer)
    • Since: gtk+ 2.6

πŸ‘‘ PROPERTIES πŸ‘‘

Every single one, bestie, and every one of them is private / static-nick / static-blurb β€” that's just how she rolls:

  • 'angle' (double : default 0 : readable / writable / private / static-nick / static-blurb) β€” Angle at which the label is rotated 🌸
  • 'attributes' (Pango::AttrList : default undef : readable / writable / private / static-nick / static-blurb) β€” A list of style attributes to apply to the text of the label
  • 'cursor-position' (integer : default 0 : readable / private / static-nick / static-blurb) β€” The current position of the insertion cursor in chars
  • 'ellipsize' (Pango::EllipsizeMode : default "none" : readable / writable / private / static-nick / static-blurb) β€” The preferred place to ellipsize the string, if the label does not have enough room to display the entire string
  • 'justify' (Gtk2::Justification : default "left" : readable / writable / private / static-nick / static-blurb) β€” The alignment of the lines in the text of the label relative to each other. This does NOT affect the alignment of the label within its allocation. See GtkMisc::xalign for that
  • 'label' (string : default "" : readable / writable / private / static-nick / static-blurb) β€” The text of the label
  • 'max-width-chars' (integer : default -1 : readable / writable / private / static-nick / static-blurb) β€” The desired maximum width of the label, in characters
  • 'mnemonic-keyval' (Glib::UInt : default 0xFFFFFF VoidSymbol : readable / private / static-nick / static-blurb) β€” The mnemonic accelerator key for this label
  • 'mnemonic-widget' (Gtk2::Widget : default undef : readable / writable / private / static-nick / static-blurb) β€” The widget to be activated when the label's mnemonic key is pressed
  • 'pattern' (string : default undef : writable / private / static-nick / static-blurb) β€” A string with _ characters in positions correspond to characters in the text to underline
  • 'selectable' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Whether the label text can be selected with the mouse
  • 'selection-bound' (integer : default 0 : readable / private / static-nick / static-blurb) β€” The position of the opposite end of the selection from the cursor in chars
  • 'single-line-mode' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Whether the label is in single line mode
  • 'track-visited-links' (boolean : default true : readable / writable / private / static-nick / static-blurb) β€” Whether visited links should be tracked
  • 'use-markup' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” The text of the label includes XML markup. See pango_parse_markup()
  • 'use-underline' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key
  • 'width-chars' (integer : default -1 : readable / writable / private / static-nick / static-blurb) β€” The desired width of the label, in characters
  • 'wrap' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” If set, wrap lines if the text becomes too wide
  • 'wrap-mode' (Pango::WrapMode : default "word" : readable / writable / private / static-nick / static-blurb) β€” If wrap is set, controls how linewrapping is done

πŸŽ€ SIGNALS πŸŽ€

The moments where she does something, and you can catch them:

  • activate-current-link (Gtk2::Label)
  • boolean = activate-link (Gtk2::Label, string)
  • copy-clipboard (Gtk2::Label)
  • move-cursor (Gtk2::Label, Gtk2::MovementStep, integer, boolean)
  • populate-popup (Gtk2::Label, Gtk2::Menu)

🌟 ENUMS AND FLAGS 🌟

enum Gtk2::Justification

  • 'left' / 'GTK_JUSTIFY_LEFT'
  • 'right' / 'GTK_JUSTIFY_RIGHT'
  • 'center' / 'GTK_JUSTIFY_CENTER'
  • 'fill' / 'GTK_JUSTIFY_FILL'

enum Gtk2::MovementStep

  • 'logical-positions' / 'GTK_MOVEMENT_LOGICAL_POSITIONS'
  • 'visual-positions' / 'GTK_MOVEMENT_VISUAL_POSITIONS'
  • 'words' / 'GTK_MOVEMENT_WORDS'
  • 'display-lines' / 'GTK_MOVEMENT_DISPLAY_LINES'
  • 'display-line-ends' / 'GTK_MOVEMENT_DISPLAY_LINE_ENDS'
  • 'paragraphs' / 'GTK_MOVEMENT_PARAGRAPHS'
  • 'paragraph-ends' / 'GTK_MOVEMENT_PARAGRAPH_ENDS'
  • 'pages' / 'GTK_MOVEMENT_PAGES'
  • 'buffer-ends' / 'GTK_MOVEMENT_BUFFER_ENDS'
  • 'horizontal-pages' / 'GTK_MOVEMENT_HORIZONTAL_PAGES'

enum Pango::EllipsizeMode

  • 'none' / 'PANGO_ELLIPSIZE_NONE'
  • 'start' / 'PANGO_ELLIPSIZE_START'
  • 'middle' / 'PANGO_ELLIPSIZE_MIDDLE'
  • 'end' / 'PANGO_ELLIPSIZE_END'

enum Pango::WrapMode

  • 'word' / 'PANGO_WRAP_WORD'
  • 'char' / 'PANGO_WRAP_CHAR'
  • 'word-char' / 'PANGO_WRAP_WORD_CHAR'
  • 'none' / 'PANGO_WRAP_NONE'

🫢 SEE ALSO 🫢

Go read these next, they're the extended universe:

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Misc


Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


okay that's the whole page bestie, mwah πŸ’… this lil masterpiece shipped with perl v5.42.0 and it's dated 2025-07-25 β€” the Gtk2::Label(3) era, and honestly? we ate. πŸ“βœ¨

πŸ“¦ where this page comes from