<html lang="en"> <head> <title>message - GCL TK Manual</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GCL TK Manual"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Widgets.html#Widgets" title="Widgets"> <link rel="prev" href="entry.html#entry" title="entry"> <link rel="next" href="frame.html#frame" title="frame"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="message"></a> <p> Next: <a rel="next" accesskey="n" href="frame.html#frame">frame</a>, Previous: <a rel="previous" accesskey="p" href="entry.html#entry">entry</a>, Up: <a rel="up" accesskey="u" href="Widgets.html#Widgets">Widgets</a> <hr> </div> <h3 class="section">2.11 message</h3> <!-- @cartouche --> <p>message \- Create and manipulate message widgets <h4 class="unnumberedsubsec">Synopsis</h4> <p><b>message</b> <i>pathName </i><span class="roman">?</span><i>options</i>? <h4 class="unnumberedsubsec">Standard Options</h4> <pre class="example"> anchor cursor padX text background font padY textVariable borderWidth foreground relief width </pre> <p>See <a href="options.html#options">options</a>, for more information. <h4 class="unnumberedsubsec">Arguments for Message</h4> <dl> <dt><b>:aspect</b><dd> <div align="right">Name=<code>"</code><b>aspect</b><span class="roman">"</span><code> Class="</code><b>Aspect</b><code>"</code> </div> <pre class="sp"> </pre> Specifies a non-negative integer value indicating desired aspect ratio for the text. The aspect ratio is specified as 100*width/height. 100 means the text should be as wide as it is tall, 200 means the text should be twice as wide as it is tall, 50 means the text should be twice as tall as it is wide, and so on. Used to choose line length for text if <b>width</b> option isn't specified. Defaults to 150. </dl> <dl> <dt><b>:justify</b><dd> <div align="right">Name=<code>"</code><b>justify</b><span class="roman">"</span><code> Class="</code><b>Justify</b><code>"</code> </div> <pre class="sp"> </pre> Specifies how to justify lines of text. Must be one of <b>left</b><span class="roman">, </span><b>center</b><span class="roman">, or </span><b>right</b>. Defaults to <b>left</b>. This option works together with the <b>anchor</b><span class="roman">, </span><b>aspect</b>, <b>padX</b><span class="roman">, </span><b>padY</b><span class="roman">, and </span><b>width</b> options to provide a variety of arrangements of the text within the window. The <b>aspect</b><span class="roman"> and </span><b>width</b> options determine the amount of screen space needed to display the text. The <b>anchor</b><span class="roman">, </span><b>padX</b><span class="roman">, and </span><b>padY</b> options determine where this rectangular area is displayed within the widget's window, and the <b>justify</b> option determines how each line is displayed within that rectangular region. For example, suppose <b>anchor</b><span class="roman"> is </span><b>e</b><span class="roman"> and </span><b>justify</b> is <b>left</b>, and that the message window is much larger than needed for the text. The the text will displayed so that the left edges of all the lines line up and the right edge of the longest line is <b>padX</b> from the right side of the window; the entire text block will be centered in the vertical span of the window. </dl> <dl> <dt><b>:width</b><dd> <div align="right">Name=<code>"</code><b>width</b><span class="roman">"</span><code> Class="</code><b>Width</b><code>"</code> </div> <pre class="sp"> </pre> Specifies the length of lines in the window. The value may have any of the forms acceptable to <b>Tk_GetPixels</b>. If this option has a value greater than zero then the <b>aspect</b> option is ignored and the <b>width</b> option determines the line length. If this option has a value less than or equal to zero, then the <b>aspect</b> option determines the line length. </dl> <!-- @end cartouche --> <h4 class="unnumberedsubsec">Description</h4> <p>The <b>message</b> command creates a new window (given by the <i>pathName</i> argument) and makes it into a message widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the message such as its colors, font, text, and initial relief. The <b>message</b> command returns its <i>pathName</i> argument. At the time this command is invoked, there must not exist a window named <i>pathName</i>, but <i>pathName</i>'s parent must exist. <p>A message is a widget that displays a textual string. A message widget has three special features. First, 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 (if not even a single word would fit on a line, then the word will be split across lines). Newline characters in the string will force line breaks; they can be used, for example, to leave blank lines in the display. <p>The second feature of a message widget is 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). <p>The third feature of a message widget is that 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 \fB\ex<i>hh</i> where <i>hh</i> is the two-digit hexadecimal number corresponding to the character. In the unusual case where the font doesn't contain all of the characters in “0123456789abcdef\ex” then control characters and undefined characters are not displayed at all. <h4 class="unnumberedsubsec">A Message Widget's Arguments</h4> <p>The <b>message</b> command creates a new Tcl command whose name is <i>pathName</i>. This command may be used to invoke various operations on the widget. It has the following general form: <pre class="example"> <i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>? </pre> <p><i>Option</i><span class="roman"> and the </span><i>arg</i>s determine the exact behavior of the command. The following commands are possible for message widgets: <dl> <dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?<dd>Query or modify the configuration options of the widget. If no <i>option</i> is specified, returns a list describing all of the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for information on the format of this list). If <i>option</i> is specified with no <i>value</i>, 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 <i>option</i> is specified). If one or more <i>option:value</i> 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. <i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>message</b> command. </dl> <h4 class="unnumberedsubsec">"Default Bindings"</h4> <p>When a new message is created, it has no default event bindings: messages are intended for output purposes only. <h4 class="unnumberedsubsec">Bugs</h4> <p>Tabs don't work very well with text that is centered or right-justified. The most common result is that the line is justified wrong. <h4 class="unnumberedsubsec">Keywords</h4> <p>message, widget </body></html>