message(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’¬ 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 name aspect, database class Aspect) β€” a non-negative integer, the desired aspect ratio for the text πŸ¦‹ and it's specified as 100*width/height. so like, 100 means the text should be as wide as it is tall, 200 means twice as wide as tall, 50 means twice as tall as wide, and so on forever and ever. it's used to pick the line length for the text when the -width option is not specified. defaults to 150. slay.
  • -justify (database name justify, database class Justify) β€” how to justify the lines of text. must be one of left, center, or right. defaults to left ⭐ this one works together with the -anchor, -aspect, -padx, -pady, and -width options to serve a whole variety of arrangements of the text inside the window, and the way that it works is genuinely so cute:
    • -aspect and -width decide how much screen space is needed to display the text.
    • -anchor, -padx, and -pady decide where that rectangular area gets displayed inside the widget's window.
    • -justify decides 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 name width, database class Width) β€” the length of lines in the window. the value can be in any of the forms acceptable to Tk_GetPixels. here's the deal tho:
    • if this option has a value greater than zero, then the -aspect option is ignored and -width determines the line length.
    • if this option's value is negative or zero, then -aspect determines the line length.

πŸ’– 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":

  1. 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.
  2. 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) πŸ’…
  3. 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 \xhh where hh is 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 by option. option may have any of the values accepted by the message command. 🫢
  • pathName configure ?option? ?value option value ...? β€” query or modify the configuration options of the widget.
    • if no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for info on the format of this list).
    • if option is specified with no value, 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 no option is specified).
    • if one or more option-value pairs 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.
    • option may have any of the values accepted by the message command.

🌈 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