message(3tk)
π¬ message(3tk) β the Tk Built-In Commands era β¨
okay bestie so this is the page for message, living in the Tk Built-In Commands section of the manual π it's giving "text widget that just sits there and looks pretty," and honestly? iconic behavior.
πΈ NAME πΈ
message β create and manipulate 'message' non-interactive text widgets π
β¨ SYNOPSIS β¨
message pathName ?options?
that's it. that's the whole vibe. π
π«Ά STANDARD OPTIONS π«Ά
these are the classics, the ones every cool widget has:
-anchor-background-borderwidth-cursor-font-foreground-highlightbackground-highlightcolor-highlightthickness-padx-pady-relief-takefocus-text-textvariable
no cap, if you want the tea on what all of those actually do, go read the options manual entry. this page isn't gonna gatekeep but it's also not gonna duplicate. iykyk π
π WIDGET-SPECIFIC OPTIONS π
these are the ones that are hers, the main character options only a message widget has. periodt.
-aspect(database nameaspect, database classAspect) β a non-negative integer, the desired aspect ratio for the text π¦ and it's specified as100*width/height. so like,100means the text should be as wide as it is tall,200means twice as wide as tall,50means twice as tall as wide, and so on forever and ever. it's used to pick the line length for the text when the-widthoption is not specified. defaults to150. slay.-justify(database namejustify, database classJustify) β how to justify the lines of text. must be one ofleft,center, orright. defaults toleftβ this one works together with the-anchor,-aspect,-padx,-pady, and-widthoptions to serve a whole variety of arrangements of the text inside the window, and the way that it works is genuinely so cute:-aspectand-widthdecide how much screen space is needed to display the text.-anchor,-padx, and-padydecide where that rectangular area gets displayed inside the widget's window.-justifydecides how each line is displayed within that rectangular region.
for example (and this is the official example, bestie, i'm not making this up): suppose -anchor is e and -justify is left, and the message window is much larger than needed for the text. the text will be displayed so that the left edges of all the lines line up, and the right edge of the longest line is -padx from the right side of the window; the entire text block will be centered in the vertical span of the window. ate. π₯
-width(database namewidth, database classWidth) β the length of lines in the window. the value can be in any of the forms acceptable toTk_GetPixels. here's the deal tho:- if this option has a value greater than zero, then the
-aspectoption is ignored and-widthdetermines the line length. - if this option's value is negative or zero, then
-aspectdetermines the line length.
- if this option has a value greater than zero, then the
π DESCRIPTION π
the message command creates a brand new window (given by the pathName argument, bestie) and makes it into a message widget. extra options β the ones we just yapped about β can be specified on the command line or in the option database to configure aspects of the message like its colors, font, text, and initial relief β¨
the message command returns its pathName argument. and at the time this command is invoked, there must not already exist a window named pathName, but pathName's parent must exist. so like, know your family tree. π
a message is a widget that displays a textual string. a message widget has three special features that differentiate it from a label widget β it's giving "i'm not like other widgets":
- it breaks up its string into lines in order to produce a given aspect ratio for the window π¦ the line breaks are chosen at word boundaries wherever possible (and if not even a single word would fit on a line, then the word will be split across lines β no word left behind). newline characters in the string will force line breaks; they can be used, for example, to leave blank lines in the display. cute.
- it does justification. the text may be displayed left-justified (each line starts at the left side of the window), centered on a line-by-line basis, or right-justified (each line ends at the right side of the window) π
- it handles control characters and non-printing characters specially. tab characters are replaced with enough blank space to line up on the next 8-character boundary. newlines cause line breaks. other control characters (ASCII code less than
0x20) and characters not defined in the font are displayed as a four-character sequence\xhhwherehhis the two-digit hexadecimal number corresponding to the character π’
and in the unusual case where the font does not contain all of the characters in β0123456789abcdef\xβ β then control characters and undefined characters are not displayed at all. yes really. nothing. gone. π
π WIDGET COMMAND π
the message command creates a new Tcl command whose name is pathName. this command may be used to invoke various operations on the widget. general form:
pathName option ?arg ...?
option and the args determine the exact behavior of the command. the following commands are possible for message widgets:
pathName cget optionβ returns the current value of the configuration option given byoption.optionmay have any of the values accepted by themessagecommand. π«ΆpathName configure ?option? ?value option value ...?β query or modify the configuration options of the widget.- if no
optionis specified, returns a list describing all of the available options forpathName(seeTk_ConfigureInfofor info on the format of this list). - if
optionis specified with novalue, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if nooptionis specified). - if one or more
option-valuepairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. optionmay have any of the values accepted by themessagecommand.
- if no
π DEFAULT BINDINGS π
when a new message is created, it has no default event bindings: messages are intended for output purposes only π she does not take input. she only serves looks.
π BUGS π
tabs do not work very well with text that is centered or right-justified. the most common result is that the line is justified wrong. so likeβ¦ yeah. known issue bestie. not me pretending it's fine. π
π SEE ALSO π
β KEYWORDS β
message, widget
and that's the whole page, babe π§ this one comes from Tk, version 4.0, dated back in the message(3tk) days β go forth and display your textual strings with impeccable aspect ratio πβ¨ππ¦πΈ
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms