options(3pm)
User Contributed Perl Documentation presentsβ¦ β¨ options(3pm) β¨ β the one where Tk tells you every standard option it knows π
πΈ NAME πΈ
Tk::options β standard options supported by widgets, and how you manipulate them π
β¨ SYNOPSIS β¨
$value = $widget->cget('-option');
$widget->configure(-option=>value ?,-option=>value ...?);
@list = $widget->configure('-option');
@lol = $widget->configure;
π¦ DESCRIPTION π¦
okay so real talk bestie: every widget and every image has one standard mechanism for setting and querying attributes/options π. It's built on two methods β configure and cget β and here's exactly how they behave:
$widget->configure(-option=>value ?,-option=>value ...?);
Sets the value of each -option to value, for every single -option=>value pair you hand it. The internal new method does an implicit configure in this form, with the options you passed in at widget create time π.
$widget->configure('-option')
In array context this returns a list of five or two elements. If -option is an alias for another option, you get back a list of the alias option and the name of the option it's an alias for, e.g. ('-bg', 'background') πͺ. If -option isn't an alias, the list has these five elements:
- Option Name β the value of
-option, e.g.-background. - Name β the option's name in the option database, e.g.
background. - Class β the option's class value in the option database, e.g.
Background. - Default β the default value for the option if it's not specified or in the option database, e.g.
grey. - Value β the current value (as returned by
cget), e.g.white.
$widget->configure
Returns a list of lists, one sub-list for every option $widget supports. Each sub-list is in the form returned by configure('-option') π. (This mechanism is what the Tk::Derived class uses to figure out the options available from a base class β iykyk.)
$widget->cget('-option')
Returns the current value of -option for $widget π«.
ngl,cget('-option')is clumsy because of the whole need for''due to perl's parsing rules. Something more subtle usingtiemight look better. π
The next few paragraphs describe the common configuration options supported by widgets in the Tk toolkit. Every widget does not necessarily support every option (go read the documentation entries for individual widgets for the list of standard options that widget supports), but if a widget does support an option with one of the names listed below, then that option has exactly the effect described below. No cap π§’.
In the descriptions below, Name'' refers to the option's name in the option database. Class'' refers to the option's class value in the option database. ``Switch'' refers to the switch used in widget-creation and configure widget methods to set this value. For example, if an option's configure option is -foreground and there exists a widget $widget, then the call:
$widget->configure(-foreground=>'black')
may be used to specify the value black for the option in the widget $widget. Configure options may be abbreviated, as long as the abbreviation is unambiguous βοΈ (abbreviation is deprecated in perl/Tk β so like, it still works but it's giving legacy).
π Creation options: Widget Name and Class π
The Name and -class options can only be specified when a widget is created, and cannot be changed with configure π«. These options determine the widget's identity and how Tk applies resource values from the option database (see Tk::option), and so they cannot be assigned by the options database. Main character options only, fr fr.
Name
- Name:
name - Switch:
Name
Specifies the path element for the widget. Names generally begin with a lowercase letter π.
Each widget has a unique pathname that follows the hierarchy from the MainWindow all the way down to the widget itself. Since the widget's PathName is used to assign options from the options database, it is important to specify a distinctive Name for any widget that will have non-default options. See Tk::option for details π
-class
- Name:
class - Switch:
-class
Specifies a class for the window. Classes generally begin with an uppercase letter π.
This class will be used when querying the option database for the window's other options (see Tk::options), and it will also be used later for other purposes such as bindings. One typically assigns a class to a TopLevel or Frame so that the class will apply to all of that widget's children β iconic inheritance behaviour π
.
π Reconfigurable options π
These options can be set at widget creation or changed later via configure π.
-activebackground
- Name:
activeBackground - Class:
Foreground - Switch:
-activebackground
Specifies the background color to use when drawing active elements. An element (a widget, or a portion of a widget) is active if the mouse cursor is positioned over the element and pressing a mouse button will cause some action to occur π±οΈ. If strict Motif compliance has been requested by setting the $Tk::strictMotif variable, this option will normally be ignored; the normal background color will be used instead. For some elements on Windows and Macintosh systems, the active color will only be used while mouse button 1 is pressed over the element π.
-activeborderwidth
- Name:
activeBorderWidth - Class:
BorderWidth - Switch:
-activeborderwidth
Specifies a non-negative value indicating the width of the 3-D border drawn around active elements. See above for the definition of active elements. The value may have any of the forms acceptable to Tk_GetPixels. This option is typically only available in widgets displaying more than one element at a time (e.g. menus but not buttons) π.
-activeforeground
- Name:
activeForeground - Class:
Background - Switch:
-activeforeground
Specifies the foreground color to use when drawing active elements. See above for the definition of active elements π¨.
-activetile
- Name:
activetile - Class:
Tile - Switch:
-activetile
Specifies the image used to display inside active elements of the widget. See above for the definition of active elements πΌοΈ.
-anchor
- Name:
anchor - Class:
Anchor - Switch:
-anchor
Specifies how the information in a widget (e.g. text or a bitmap) is to be displayed in the widget. Must be one of the values n, ne, e, se, s, sw, w, nw, or center π§. For example, nw means display the information such that its top-left corner is at the top-left corner of the widget.
-background
- Name:
background - Class:
Background - Switch:
-background - Alias:
-bg
Specifies the normal background color to use when displaying the widget π.
-bitmap
- Name:
bitmap - Class:
Bitmap - Switch:
-bitmap
Specifies a bitmap to display in the widget, in any of the forms acceptable to Tk_GetBitmap. The exact way in which the bitmap is displayed may be affected by other options such as -anchor or -justify. Typically, if this option is specified then it overrides other options that specify a textual value to display in the widget; the -bitmap option may be reset to an empty string to re-enable a text display. In widgets that support both -bitmap and -image options, -image will usually override -bitmap π.
-borderwidth
- Name:
borderWidth - Class:
BorderWidth - Switch:
-borderwidth - Alias:
-bd
Specifies a non-negative value indicating the width of the 3-D border to draw around the outside of the widget (if such a border is being drawn; the relief option typically determines this). The value may also be used when drawing 3-D effects in the interior of the widget. The value may have any of the forms acceptable to Tk_GetPixels π.
-compound
- Name:
compound - Class:
Compound - Switch:
-compound
Specifies if the widget should display text and bitmaps/images at the same time, and if so, where the bitmap/image should be placed relative to the text. Must be one of the values none, bottom, top, left, right, or center π§©. For example, the (default) value none specifies that the bitmap or image should (if defined) be displayed instead of the text, the value left specifies that the bitmap or image should be displayed to the left of the text, and the value center specifies that the bitmap or image should be displayed on top of the text.
-cursor
- Name:
cursor - Class:
Cursor - Switch:
-cursor
Specifies the mouse cursor to be used for the widget. The value may have any of the forms acceptable to Tk_GetCursor π±οΈβ¨.
-dash
- Name:
dash - Class:
Dash - Switch:
-dash
The value may have any of the forms accepted by Tk_GetDash, such as 4, [6,4], ., -, -., or -... β.
-dashoffset
- Name:
dashoffset - Class:
Dashoffset - Switch:
-dashoffset
Specifies the offset in the dash list where the drawing starts π―.
-disabledforeground
- Name:
disabledForeground - Class:
DisabledForeground - Switch:
-disabledforeground
Specifies the foreground color to use when drawing a disabled element. If the option is specified as an empty string (which is typically the case on monochrome displays), disabled elements are drawn with the normal foreground color but they are dimmed by drawing them with a stippled fill pattern πΆπ«οΈ.
-disabledtile
- Name:
disabledtile - Class:
Tile - Switch:
-disabledtile
Specifies the image to use when drawing a disabled element π«πΌοΈ.
-exportselection
- Name:
exportSelection - Class:
ExportSelection - Switch:
-exportselection
Specifies whether or not a selection in the widget should also be the X selection. The value may have any of the forms accepted by Tcl_GetBoolean, such as true, false, 0, 1, yes, or no β
. If the selection is exported, then selecting in the widget deselects the current X selection, selecting outside the widget deselects any widget selection, and the widget will respond to selection retrieval requests when it has a selection. The default is usually for widgets to export selections π€.
-font
- Name:
font - Class:
Font - Switch:
-font
Specifies the font to use when drawing text inside the widget π€.
-foreground
- Name:
foreground - Class:
Foreground - Switch:
-foreground - Alias:
-fg
Specifies the normal foreground color to use when displaying the widget π.
-highlightbackground
- Name:
highlightBackground - Class:
HighlightBackground - Switch:
-highlightbackground
Specifies the color to display in the traversal highlight region when the widget does not have the input focus π βοΈ.
-highlightcolor
- Name:
highlightColor - Class:
HighlightColor - Switch:
-highlightcolor
Specifies the color to use for the traversal highlight rectangle that is drawn around the widget when it has the input focus β¨π.
β¦and that's where part 1 leaves us bestie, more options incoming π«Ά
-highlightthicknessβ Name:highlightThickness; Class:HighlightThickness; Switch:-highlightthickness. Okay so this one is all about the focus glow around the outside of the widget when it has the input focus. It takes a non-negative value, and the value can be any of the forms acceptable toTk_GetPixels. If the value is zero, no focus highlight is drawn around the widget. Periodt. π-imageβ Name:image; Class:Image; Switch:-image. Specifies an image to display in the widget, which must have been created with animage create. (SeeTk::Imagefor details of image creation.) Typically, if the-imageoption is specified then it overrides other options that specify a bitmap or textual value to display in the widget; the-imageoption may be reset to an empty string to re-enable a bitmap or text display. π¦-insertbackgroundβ Name:insertBackground; Class:Foreground; Switch:-insertbackground. Specifies the color to use as background in the area covered by the insertion cursor. This color will normally override either the normal background for the widget (or the selection background if the insertion cursor happens to fall in the selection). π-insertborderwidthβ Name:insertBorderWidth; Class:BorderWidth; Switch:-insertborderwidth. Specifies a non-negative value indicating the width of the 3-D border to draw around the insertion cursor. The value may have any of the forms acceptable toTk_GetPixels. β¨-insertofftimeβ Name:insertOffTime; Class:OffTime; Switch:-insertofftime. Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain "off" in each blink cycle. If this option is zero then the cursor doesn't blink: it is on all the time. Not me thinking a non-blinking cursor is lowkey iconic. π-insertontimeβ Name:insertOnTime; Class:OnTime; Switch:-insertontime. Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain "on" in each blink cycle. π-insertwidthβ Name:insertWidth; Class:InsertWidth; Switch:-insertwidth. Specifies a value indicating the total width of the insertion cursor. The value may have any of the forms acceptable toTk_GetPixels. If a border has been specified for the insertion cursor (using theinsertBorderWidthoption), the border will be drawn inside the width specified by theinsertWidthoption. π-jumpβ Name:jump; Class:Jump; Switch:-jump. For widgets with a slider that can be dragged to adjust a value, such as scrollbars, this option determines when notifications are made about changes in the value. The option's value must be a boolean of the form accepted byTcl_GetBoolean. If the value is false, updates are made continuously as the slider is dragged. If the value is true, updates are delayed until the mouse button is released to end the drag; at that point a single notification is made (the value "jumps" rather than changing smoothly). π₯-justifyβ Name:justify; Class:Justify; Switch:-justify. When there are multiple lines of text displayed in a widget, this option determines how the lines line up with each other. Must be one ofleft,center, orright.leftmeans that the lines' left edges all line up,centermeans that the lines' centers are aligned, andrightmeans that the lines' right edges line up. The way that alignment just ties the whole vibe together. π-offsetβ Name:offset; Class:Offset; Switch:-offset. Specifies the offset of tiles (see also-tileoption). It can have two different formats-offset x,yor-offset side, where side can ben,ne,e,se,s,sw,w,nw, orcenter. In the first case the origin is the origin of the toplevel of the current window. For the canvas itself and canvas objects the origin is the canvas origin, but putting#in front of the coordinate pair indicates using the toplevel origin in stead. For canvas objects, the-offsetoption is used for stippling as well. For thelineandpolygoncanvas items you can also specify an index as argument, which connects the stipple or tile origin to one of the coordinate points of the line/polygon. πΌοΈ-orientβ Name:orient; Class:Orient; Switch:-orient. For widgets that can lay themselves out with either a horizontal or vertical orientation, such as scrollbars, this option specifies which orientation should be used. Must be eitherhorizontalorverticalor an abbreviation of one of these. π-padxβ Name:padX; Class:Pad; Switch:-padx. Specifies a non-negative value indicating how much extra space to request for the widget in the X-direction. The value may have any of the forms acceptable toTk_GetPixels. When computing how large a window it needs, the widget will add this amount to the width it would normally need (as determined by the width of the things displayed in the widget); if the geometry manager can satisfy this request, the widget will end up with extra internal space to the left and/or right of what it displays inside. Most widgets only use this option for padding text: if they are displaying a bitmap or image, then they usually ignore padding options. π«Ά-padyβ Name:padY; Class:Pad; Switch:-pady. Specifies a non-negative value indicating how much extra space to request for the widget in the Y-direction. The value may have any of the forms acceptable toTk_GetPixels. When computing how large a window it needs, the widget will add this amount to the height it would normally need (as determined by the height of the things displayed in the widget); if the geometry manager can satisfy this request, the widget will end up with extra internal space above and/or below what it displays inside. Most widgets only use this option for padding text: if they are displaying a bitmap or image, then they usually ignore padding options. π-reliefβ Name:relief; Class:Relief; Switch:-relief. Specifies the 3-D effect desired for the widget. Acceptable values areraised,sunken,flat,ridge,solid, andgroove. The value indicates how the interior of the widget should appear relative to its exterior; for example,raisedmeans the interior of the widget should appear to protrude from the screen, relative to the exterior of the widget. β¨-repeatdelayβ Name:repeatDelay; Class:RepeatDelay; Switch:-repeatdelay. Specifies the number of milliseconds a button or key must be held down before it begins to auto-repeat. Used, for example, on the up- and down-arrows in scrollbars. π-repeatintervalβ Name:repeatInterval; Class:RepeatInterval; Switch:-repeatinterval. Used in conjunction withrepeatDelay: once auto-repeat begins, this option determines the number of milliseconds between auto-repeats. π-selectbackgroundβ Name:selectBackground; Class:Foreground; Switch:-selectbackground. Specifies the background color to use when displaying selected items. π-selectborderwidthβ Name:selectBorderWidth; Class:BorderWidth; Switch:-selectborderwidth. Specifies a non-negative value indicating the width of the 3-D border to draw around selected items. The value may have any of the forms acceptable toTk_GetPixels. π-selectforegroundβ Name:selectForeground; Class:Background; Switch:-selectforeground. Specifies the foreground color to use when displaying selected items. πΈ-setgridβ Name:setGrid; Class:SetGrid; Switch:-setgrid. Specifies a boolean value that determines whether this widget controls the resizing grid for its top-level window. This option is typically used in text widgets, where the information in the widget has a natural size (the size of a character) and it makes sense for the window's dimensions to be integral numbers of these units. These natural window sizes form a grid. If thesetGridoption is set to true then the widget will communicate with the window manager so that when the user interactively resizes the top-level window that contains the widget, the dimensions of the window will be displayed to the user in grid units and the window size will be constrained to integral numbers of grid units. See "GRIDDED GEOMETRY MANAGEMENT" inTk::Wmfor more details. π§-takefocusβ Name:takeFocus; Class:TakeFocus; Switch:-takefocus. Determines whether the window accepts the focus during keyboard traversal (e.g., Tab and Shift-Tab). Before setting the focus to a window, the traversal scripts consult the value of thetakeFocusoption. A value of0means that the window should be skipped entirely during keyboard traversal.1means that the window should receive the input focus as long as it is viewable (it and all of its ancestors are mapped). An empty value for the option means that the traversal scripts make the decision about whether or not to focus on the window: the current algorithm is to skip the window if it is disabled, if it has no key bindings, or if it is not viewable. If the value has any other form, then the traversal scripts take the value, append the name of the window to it (with a separator space), and evaluate the resulting string as aCallback. The script must return0,1, or an empty string: a0or1value specifies whether the window will receive the input focus, and an empty string results in the default decision described above. Note: this interpretation of the option is defined entirely by theCallbacks that implement traversal: the widget implementations ignore the option entirely, so you can change its meaning if you redefine the keyboard traversal scripts. π-textβ Name:text; Class:Text; Switch:-text. Specifies a string to be displayed inside the widget. The way in which the string is displayed depends on the particular widget and may be determined by other options, such asanchororjustify. π¬-textvariableβ Name:textVariable; Class:Variable; Switch:-textvariable. Specifies the name of a variable. The value of the variable is a text string to be displayed inside the widget; if the variable value changes then the widget will automatically update itself to reflect the new value. The way in which the string is displayed in the widget depends on the particular widget and may be determined by other options, such asanchororjustify. π-tileβ Name:tile, Class:Tile. Specifies image used to display the widget. If image is the empty string, then the normal background color is displayed. Iconic. π-troughcolorβ Name:troughColor, Class:Background. Specifies the color to use for the rectangular trough areas in widgets such as scrollbars and scales. It's giving groove realness. π-troughtileβ Name:troughTile, Class:Tile. Specifies image used to display in the rectangular trough areas in widgets such as scrollbars and scales. Same trough, but make it an image. β¨-underlineβ Name:underline, Class:Underline. Specifies the integer index of a character to underline in the widget. This option is used by the default bindings to implement keyboard traversal for menu buttons and menu entries.0corresponds to the first character of the text displayed in the widget,1to the next character, and so on. Keyboard navigation? We love to see it. π-wraplengthβ Name:wrapLength, Class:WrapLength. For widgets that can perform word-wrapping, this option specifies the maximum line length. Lines that would exceed this length are wrapped onto the next line, so that no line is longer than the specified length. The value may be specified in any of the standard forms for screen distances. If this value is less than or equal to0then no wrapping is done: lines will break only at newline characters in the text. No wrapping, no problem. π-xscrollcommandβ Name:xScrollCommand, Class:ScrollCommand. Specifies a callback used to communicate with horizontal scrollbars. When the view in the widget's window changes (or whenever anything else occurs that could change the display in a scrollbar, such as a change in the total size of the widget's contents), the widget will make a callback passing two numeric arguments in addition to any specified in the callback. Each of the numbers is a fraction between0and1, which indicates a position in the document.0indicates the beginning of the document,1indicates the end,.333indicates a position one third the way through the document, and so on. The first fraction indicates the first information in the document that is visible in the window, and the second fraction indicates the information just after the last portion that is visible. Typically thexScrollCommandoption consists of the scrollbar widget object and the methodseti.e.[set => $sb]: this will cause the scrollbar to be updated whenever the view in the window changes. If this option is not specified, then no command will be executed. Scrollbar communication? Periodt. π-yscrollcommandβ Name:yScrollCommand, Class:ScrollCommand. Specifies a callback used to communicate with vertical scrollbars. This option is treated in the same way as thexScrollCommandoption, except that it is used for vertical scrollbars and is provided by widgets that support vertical scrolling. See the description ofxScrollCommandfor details on how this option is used. Vertical scrollbars, rise up. π¦
π SEE ALSO π
Tk::optionTk::callbacksTk::ConfigSpecsTk_GetPixels
β¨ KEYWORDS β¨
classnamestandard optionswitch
π That's the tea! This page is from perl v5.40.1, dated 2025-04-13, and it's the options(3pm) manual page. Stay iconic, bestie! π
π¦ 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