Gtk2::Entry(3)

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

πŸ’– Gtk2::Entry β€” the manual page, bestie edition πŸ’–

okay so. Gtk2::Entry(3) β€” that's the page we're on, from the User Contributed Perl Documentation corner of the world. It's a wrapper for GtkEntry. That's it. That's the vibe. One line of text box energy and honestly? iconic.


✨ HIERARCHY ✨

the family tree, no cap. this is where Entry sits in the whole ancestry situation:

  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::Entry

it's giving "descended from greatness" fr fr πŸ’…


πŸ¦‹ INTERFACES πŸ¦‹

these are the interfaces it implements β€” the little personality traits it picked up along the way:

  • Glib::Object::_Unregistered::AtkImplementorIface
  • Gtk2::Buildable
  • Gtk2::Editable
  • Gtk2::CellEditable

so it can be built, it can be edited, it can be edited in a cell. versatile queen πŸ‘‘


🌸 METHODS 🌸

this is the big one. buckle up, there's a LOT. take it slow, hydrate, we got this.

widget = Gtk2::Entry->new

make a fresh lil Entry. blank slate. main character debut ✨

widget = Gtk2::Entry->new_with_buffer ($buffer)

  • $buffer (Gtk2::EntryBuffer)
Since: gtk+ 2.18

same but you hand it a buffer to live in.

widget = Gtk2::Entry->new_with_max_length ($max)

  • $max (integer)

new entry, but it comes with a character limit already installed. built different.

boolean = $entry->get_activates_default / $entry->set_activates_default ($setting)

  • $setting (boolean)

get/set whether hitting enter in here triggers the default widget. the "just press go" setting πŸ’…

double = $entry->get_alignment

Since: gtk+ 2.4

$entry->set_alignment ($xalign)

  • $xalign (double)
Since: gtk+ 2.4

how far left/right the text sits in the box. alignment check, but make it literal ✨

$entry->append_text ($text)

  • $text (string)

stick text on the end. the "and also" of text entry.

entrybuffer = $entry->get_buffer

Since: gtk+ 2.18

$entry->set_buffer ($buffer)

  • $buffer (Gtk2::EntryBuffer)
Since: gtk+ 2.18

the buffer is where the actual text lives. you can grab it or swap it out.

entrycompletion or undef = $entry->get_completion

Since: gtk+ 2.4

$entry->set_completion ($completion)

  • $completion (Gtk2::EntryCompletion or undef)
Since: gtk+ 2.4

autocomplete bestie! may be undef, so check before you use it, fr.

integer = $entry->get_current_icon_drag_source

Since: gtk+ 2.16

which icon is currently being dragged from. a whole integer for that. sure.

adjustment or undef = $entry->get_cursor_hadjustment

Since: gtk+ 2.12

$entry->set_cursor_hadjustment ($adjustment)

  • $adjustment (Gtk2::Adjustment or undef)
Since: gtk+ 2.12

horizontal scrolling behavior for the cursor. can be undef, no biggie.

$entry->set_editable ($editable)

  • $editable (boolean)

can the user actually type in it or is it just for show. read-only mode is valid too πŸ‘‘

boolean = $entry->get_has_frame / $entry->set_has_frame ($setting)

  • $setting (boolean)

does it have the cute little border frame around it. aesthetic choice, honestly.

boolean = $entry->get_icon_activatable ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

$entry->set_icon_activatable ($icon_pos, $activatable)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $activatable (boolean)
Since: gtk+ 2.16

can you click the icon. yes/no. $icon_pos tells it which icon you mean.

integer = $entry->get_icon_at_pos ($x, $y)

  • $x (integer)
  • $y (integer)
Since: gtk+ 2.16

give it coordinates, it tells you which icon is sitting there. coordinate girlie πŸ”₯

$entry->set_icon_drag_source ($icon_pos, $target_list, $actions)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $target_list (Gtk2::TargetList)
  • $actions (Gtk2::Gdk::DragAction)
Since: gtk+ 2.16

make an icon draggable. drag source era.

$entry->set_icon_from_icon_name ($icon_pos, $icon_name)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $icon_name (string or undef)
Since: gtk+ 2.16

set the icon by name. undef is allowed, so you can clear it too.

$entry->set_icon_from_pixbuf ($icon_pos, $pixbuf)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $pixbuf (Gtk2::Gdk::Pixbuf or undef)
Since: gtk+ 2.16

set the icon from a pixbuf. also accepts undef. flexible πŸ’…

$entry->set_icon_from_stock ($icon_pos, $stock_id)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $stock_id (string or undef)
Since: gtk+ 2.16

stock icon by id. undef clears it, as usual.

string or undef = $entry->get_icon_name ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

grab the icon name. might be undef! check it, bestie.

pixbuf or undef = $entry->get_icon_pixbuf ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

grab the pixbuf. also possibly undef.

boolean = $entry->get_icon_sensitive ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

$entry->set_icon_sensitive ($icon_pos, $sensitive)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $sensitive (boolean)
Since: gtk+ 2.16

is the icon "sensitive" (i.e. reacting to input). set it, get it, slay.

string or undef = $entry->get_icon_stock ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

the stock id of that icon. undef possible, obviously.

imagetype = $entry->get_icon_storage_type ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

what kind of image storage this icon uses. the lore ✨

string or undef = $entry->get_icon_tooltip_markup ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

$entry->set_icon_tooltip_markup ($icon_pos, $tooltip)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $tooltip (string or undef)
Since: gtk+ 2.16

tooltip, but with markup. undef is fine, it's fine, everything's fine.

string or undef = $entry->get_icon_tooltip_text ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.16

$entry->set_icon_tooltip_text ($icon_pos, $tooltip)

  • $icon_pos (Gtk2::EntryIconPosition)
  • $tooltip (string or undef)
Since: gtk+ 2.16

plain text tooltip version. the markup one and this one are siblings, don't mix them up.

window = $entry->get_icon_window ($icon_pos)

  • $icon_pos (Gtk2::EntryIconPosition)
Since: gtk+ 2.20

the actual window for that icon. window era 🌈

boolean = $entry->im_context_filter_keypress ($event)

  • $event (Gtk2::Gdk::Event)
Since: gtk+ 2.22

filter a keypress through the input method context. returns a boolean. iykyk.

border or undef = $entry->get_inner_border

Since: gtk+ 2.10

$entry->set_inner_border ($border)

  • $border (Gtk2::Border or undef)
Since: gtk+ 2.10

the inner border. can be undef. get it, set it, move on.

character = $entry->get_invisible_char / $entry->set_invisible_char ($ch)

  • $ch (character)

which character shows up when the text is invisible (password mode, we see you πŸ‘€).

layout = $entry->get_layout

grab the Pango layout the entry is using.

integer = $entry->layout_index_to_text_index ($layout_index)

  • $layout_index (integer)
Since: gtk+ 2.6

translate a layout index into a text index. two different numbering systems, one little converter. obsessed.

(x, y) = $entry->get_layout_offsets

returns both offsets at once. list context girlie πŸ’…

integer = $entry->get_max_length / $entry->set_max_length ($max)

  • $max (integer)

get or set the max number of characters. the limit does exist.

boolean = $entry->get_overwrite_mode

Since: gtk+ 2.14

$entry->set_overwrite_mode ($overwrite)

  • $overwrite (boolean)
Since: gtk+ 2.14

overwrite mode instead of insert mode. retro typing vibe fr.

$entry->set_position ($position)

  • $position (integer)

put the cursor at a position. simple. clean. iconic.

$entry->prepend_text ($text)

  • $text (string)

text at the FRONT. the opposite of append_text. balance ✨

double = $entry->get_progress_fraction

Since: gtk+ 2.16

$entry->set_progress_fraction ($fraction)

  • $fraction (double)
Since: gtk+ 2.16

progress bar inside your text entry. how much is done. a double. go off.

$entry->progress_pulse

Since: gtk+ 2.16

pulse the progress bar forward. the lil "still working on it" wiggle.

double = $entry->get_progress_pulse_step

Since: gtk+ 2.16

$entry->set_progress_pulse_step ($fraction)

  • $fraction (double)
Since: gtk+ 2.16

how big each pulse step is. tune it to taste.

$entry->reset_im_context

Since: gtk+ 2.22

reset the input method context. clean slate for the IM.

$entry->select_region ($start, $end)

  • $start (integer)
  • $end (integer)

select a range of text programmatically. highlight it, bestie πŸ’…

string = $entry->get_text

get the text. the whole point, honestly.

integer = $entry->text_index_to_layout_index ($text_index)

  • $text_index (integer)
Since: gtk+ 2.6

the reverse converter of layout_index_to_text_index. they're a matching set 🫢

unsigned = $entry->get_text_length

Since: gtk+ 2.14

how long the text is. unsigned. count it.

$entry->set_text ($text)

  • $text (string)

set the text. the other whole point.

window = $entry->get_text_window

Since: gtk+ 2.20

the window for the text area itself. yes, separately. two windows, because why not.

$entry->unset_invisible_char

Since: gtk+ 2.16

undo the invisible char. back to default behavior, periodt.

boolean = $entry->get_visibility / $entry->set_visibility ($visible)

  • $visible (boolean)

is the text visible or hidden. the password-mode toggle, lowkey.

integer = $entry->get_width_chars / $entry->set_width_chars ($n_chars)

  • $n_chars (integer)

how wide the entry is, measured in characters. $n_chars of them, exactly.


okay bestie that's part 1 and there is more coming so don't go anywhere πŸ’–

πŸ’– PROPERTIES πŸ’–

okay bestie, this is the full property menu. every bullet is name β€” type : default value : flags β€” then the vibe. no skips, no cap. πŸ’…

  • 'activates-default' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether to activate the default widget (like the default button in a dialog) when Enter is pressed. ✨
  • 'buffer' β€” Gtk2::EntryBuffer : default undef : readable / writable / construct / private / static-nick / static-blurb β€” Text buffer object which actually stores entry text. the storage bestie. πŸŽ€
  • 'caps-lock-warning' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” Whether password entries will show a warning when Caps Lock is on. iconic. πŸ”₯
  • 'cursor-position' β€” integer : default 0 : readable / private / static-nick / static-blurb β€” The current position of the insertion cursor in chars. read-only vibes. πŸ‘€
  • 'editable' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” Whether the entry contents can be edited. that's the whole question. πŸ’…
  • 'has-frame' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” FALSE removes outside bevel from entry. no frame, no problem. ✨
  • 'im-module' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” Which IM module should be used. that's it, that's the tweet. πŸ¦‹
  • 'inner-border' β€” Gtk2::Border : default undef : readable / writable / private / static-nick / static-blurb β€” Border between text and frame. Overrides the inner-border style property. boss move. πŸ‘‘
  • 'invisible-char' β€” Glib::UInt : default 42 "*" : readable / writable / private / static-nick / static-blurb β€” The character to use when masking entry contents (in "password mode"). default is 42 "*", yes really. πŸ™ˆ
  • 'invisible-char-set' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether the invisible char has been set. yes or no bestie. 🌸
  • 'max-length' β€” integer : default 0 : readable / writable / private / static-nick / static-blurb β€” Maximum number of characters for this entry. Zero if no maximum. 0 means no maximum. periodt. πŸ’œ
  • 'overwrite-mode' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether new text overwrites existing text. type-over mode energy. ✨
  • 'primary-icon-activatable' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether the primary icon is activatable. yes/no. πŸŽ€
  • 'primary-icon-gicon' β€” Glib::Object::_Unregistered::GIcon : default undef : readable / writable / private / static-nick / static-blurb β€” GIcon for primary icon. exactly that. 🌈
  • 'primary-icon-name' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” Icon name for primary icon. name drop. πŸ’…
  • 'primary-icon-pixbuf' β€” Gtk2::Gdk::Pixbuf : default undef : readable / writable / private / static-nick / static-blurb β€” Primary pixbuf for the entry. pixels, but make it primary. ✨
  • 'primary-icon-sensitive' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” Whether the primary icon is sensitive. default says yes. πŸ₯Ί
  • 'primary-icon-stock' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” Stock ID for primary icon. old-school but valid. πŸ‘‘
  • 'primary-icon-storage-type' β€” Gtk2::ImageType : default "empty" : readable / private / static-nick / static-blurb β€” The representation being used for primary icon. read-only, default "empty". 🫢
  • 'primary-icon-tooltip-markup' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” The contents of the tooltip on the primary icon. markup edition. πŸŽ€
  • 'primary-icon-tooltip-text' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” The contents of the tooltip on the primary icon. same tooltip energy, text edition. ✨
  • 'progress-fraction' β€” double : default 0 : readable / writable / private / static-nick / static-blurb β€” The current fraction of the task that's been completed. progress bar moment. πŸ”₯
  • 'progress-pulse-step' β€” double : default 0.1 : readable / writable / private / static-nick / static-blurb β€” The fraction of total entry width to move the progress bouncing block for each call to gtk_entry_progress_pulse(). bouncing block supremacy. πŸ’…
  • 'scroll-offset' β€” integer : default 0 : readable / private / static-nick / static-blurb β€” Number of pixels of the entry scrolled off the screen to the left. read-only. πŸ‘€
  • 'secondary-icon-activatable' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether the secondary icon is activatable. the sequel. πŸ’…
  • 'secondary-icon-gicon' β€” Glib::Object::_Unregistered::GIcon : default undef : readable / writable / private / static-nick / static-blurb β€” GIcon for secondary icon. matching set. ✨
  • 'secondary-icon-name' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” Icon name for secondary icon. πŸ’–
  • 'secondary-icon-pixbuf' β€” Gtk2::Gdk::Pixbuf : default undef : readable / writable / private / static-nick / static-blurb β€” Secondary pixbuf for the entry. the other pixbuf. πŸŽ€
  • 'secondary-icon-sensitive' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” Whether the secondary icon is sensitive. default yes, be gentle. πŸ₯Ί
  • 'secondary-icon-stock' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” Stock ID for secondary icon. vintage. πŸ‘‘
  • 'secondary-icon-storage-type' β€” Gtk2::ImageType : default "empty" : readable / private / static-nick / static-blurb β€” The representation being used for secondary icon. read-only, default "empty". 🫢
  • 'secondary-icon-tooltip-markup' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” The contents of the tooltip on the secondary icon. markup flavor. πŸŽ€
  • 'secondary-icon-tooltip-text' β€” string : default undef : readable / writable / private / static-nick / static-blurb β€” The contents of the tooltip on the secondary icon. same but text flavor. ✨
  • '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. read-only. πŸ‘€
  • 'shadow-type' β€” Gtk2::ShadowType : default "in" : readable / writable / private / static-nick / static-blurb β€” Which kind of shadow to draw around the entry when has-frame is set. default "in". 🌈
  • 'text' β€” string : default "" : readable / writable / private / static-nick / static-blurb β€” The contents of the entry. main character. πŸ‘‘
  • 'text-length' β€” Glib::UInt : default 0 : readable / private / static-nick / static-blurb β€” Length of the text currently in the entry. read-only. ✨
  • 'truncate-multiline' β€” boolean : default false : readable / writable / private / static-nick / static-blurb β€” Whether to truncate multiline pastes to one line. yes/no. πŸŽ€
  • 'visibility' β€” boolean : default true : readable / writable / private / static-nick / static-blurb β€” FALSE displays the "invisible char" instead of the actual text (password mode). password mode, bestie. πŸ™ˆ
  • 'width-chars' β€” integer : default -1 : readable / writable / private / static-nick / static-blurb β€” Number of characters to leave space for in the entry. default -1. πŸ’…
  • 'xalign' β€” float : default 0 : readable / writable / private / static-nick / static-blurb β€” The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts. ✨

🌸 STYLE PROPERTIES 🌸

these are the style-property girlies. same deal: name, type/default/flags, then the vibe. πŸ’œ

  • 'icon-prelight' β€” boolean : default true : readable / private / static-nick / static-blurb β€” Whether activatable icons should prelight when hovered. default true. ✨
  • 'inner-border' β€” Gtk2::Border : default undef : readable / private / static-nick / static-blurb β€” Border between text and frame. simple. πŸ’…
  • 'invisible-char' β€” Glib::UInt : default 0 "\0" : readable / private / static-nick / static-blurb β€” The character to use when masking entry contents (in "password mode"). default 0 "\0" β€” yes, the null char is here. πŸ™ˆ
  • 'progress-border' β€” Gtk2::Border : default undef : readable / private / static-nick / static-blurb β€” Border around the progress bar. cute. πŸŽ€
  • 'state-hint' β€” boolean : default false : readable / private / static-nick / static-blurb β€” Whether to pass a proper state when drawing shadow or background. default false. 🌈

πŸ”₯ SIGNALS πŸ”₯

here's the signal lineup, with exact signatures. no invented lore, just the facts. πŸ‘‘

  • activate (Gtk2::Entry)
  • backspace (Gtk2::Entry)
  • copy-clipboard (Gtk2::Entry)
  • cut-clipboard (Gtk2::Entry)
  • delete-from-cursor (Gtk2::Entry, Gtk2::DeleteType, integer)
  • icon-press (Gtk2::Entry, Gtk2::EntryIconPosition, Gtk2::Gdk::Event)
  • icon-release (Gtk2::Entry, Gtk2::EntryIconPosition, Gtk2::Gdk::Event)
  • insert-at-cursor (Gtk2::Entry, string)
  • move-cursor (Gtk2::Entry, Gtk2::MovementStep, integer, boolean)
  • paste-clipboard (Gtk2::Entry)
  • populate-popup (Gtk2::Entry, Gtk2::Menu)
  • preedit-changed (Gtk2::Entry, string)
  • toggle-overwrite (Gtk2::Entry)

πŸ’œ ENUMS AND FLAGS πŸ’œ

🌈 enum Gtk2::DeleteType

  • 'chars' / 'GTK_DELETE_CHARS'
  • 'word-ends' / 'GTK_DELETE_WORD_ENDS'
  • 'words' / 'GTK_DELETE_WORDS'
  • 'display-lines' / 'GTK_DELETE_DISPLAY_LINES'
  • 'display-line-ends' / 'GTK_DELETE_DISPLAY_LINE_ENDS'
  • 'paragraph-ends' / 'GTK_DELETE_PARAGRAPH_ENDS'
  • 'paragraphs' / 'GTK_DELETE_PARAGRAPHS'
  • 'whitespace' / 'GTK_DELETE_WHITESPACE'

πŸŽ€ enum Gtk2::EntryIconPosition

  • 'primary' / 'GTK_ENTRY_ICON_PRIMARY'
  • 'secondary' / 'GTK_ENTRY_ICON_SECONDARY'

✨ flags Gtk2::Gdk::DragAction

  • 'default' / 'GDK_ACTION_DEFAULT'
  • 'copy' / 'GDK_ACTION_COPY'
  • 'move' / 'GDK_ACTION_MOVE'
  • 'link' / 'GDK_ACTION_LINK'
  • 'private' / 'GDK_ACTION_PRIVATE'
  • 'ask' / 'GDK_ACTION_ASK'

🌸 enum Gtk2::ImageType

  • 'empty' / 'GTK_IMAGE_EMPTY'
  • 'pixmap' / 'GTK_IMAGE_PIXMAP'
  • 'image' / 'GTK_IMAGE_IMAGE'
  • 'pixbuf' / 'GTK_IMAGE_PIXBUF'
  • 'stock' / 'GTK_IMAGE_STOCK'
  • 'icon-set' / 'GTK_IMAGE_ICON_SET'
  • 'animation' / 'GTK_IMAGE_ANIMATION'
  • 'icon-name' / 'GTK_IMAGE_ICON_NAME'
  • 'gicon' / 'GTK_IMAGE_GICON'

πŸ’… 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 Gtk2::ShadowType

  • 'none' / 'GTK_SHADOW_NONE'
  • 'in' / 'GTK_SHADOW_IN'
  • 'out' / 'GTK_SHADOW_OUT'
  • 'etched-in' / 'GTK_SHADOW_ETCHED_IN'
  • 'etched-out' / 'GTK_SHADOW_ETCHED_OUT'

🫢 SEE ALSO 🫢

  • Gtk2
  • Glib::Object
  • Glib::InitiallyUnowned
  • Gtk2::Object
  • Gtk2::Widget

Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.

this page is perl v5.42.0, dated 2025-07-25, and it's Gtk2::Entry(3) β€” bye bestie, hydrate and read your docs πŸ’–βœ¨

πŸ“¦ where this page comes from