message
Guide: Frames, labels, and buttons
Makes a message: a widget that shows a text of more than one line.
message PATHNAME ?OPTION VALUE ...?
Description
Makes a message widget with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A message shows a text and breaks it into lines at spaces. With -width 0, the ratio of -aspect sets the length of the lines. A message runs no script.
The parent of PATHNAME must exist, and PATHNAME must not. A message is a Message in CSS and for the option database, and ztk::class gives it a style class for a stylesheet.
Widget commands
| Command | Description |
|---|---|
message cget | Gives the value of an option of the message. |
message configure | Gives or sets the options of the message. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-anchor | anchor | center | anchor | The place of the content in a message larger than it. |
-aspect | integer | 150 | aspect | The ratio of the width to the height of the text, in percent. |
-background | color | #d9d9d9 | background | The background color of the message. |
-borderwidth | screen distance | 0 | borderWidth | The width of the border of the message. |
-cursor | cursor name | empty | cursor | The shape of the pointer over the message. |
-font | font | TkDefaultFont | font | The font of the text. |
-foreground | color | #000000 | foreground | The color of the text. |
-highlightbackground | color | #d9d9d9 | highlightBackground | The color of the focus ring while the message has no focus, in the look of Tk on X11. |
-highlightcolor | color | #000000 | highlightColor | The color of the focus ring while the message has the focus, in the look of Tk on X11. |
-highlightthickness | screen distance | 0 | highlightThickness | The width of the focus ring, in the look of Tk on X11. |
-justify | justification | left | justify | The alignment of the lines of the text. |
-padx | screen distance | -1 | padX | The space at the left and the right of the content. |
-pady | screen distance | -1 | padY | The space above and below the content. |
-relief | relief | flat | relief | The 3-D look of the border. |
-takefocus | string | 0 | takeFocus | Whether the Tab key can move the focus to the message. |
-text | string | empty | text | The text of the message. |
-textvariable | variable name | empty | textVariable | A global variable whose value is the text of the message. |
-width | screen distance | 0 | width | The length of the lines of the text. |
-anchor ANCHOR
The place of the content in a message larger than it.
When the message is larger than its text, the anchor puts the text at that side or corner. center puts it in the middle.
Values: n, ne, e, se, s, sw, w, nw, center.
% message .anchor -anchor w
> .anchor cget -anchor
w% message .anchor2 -anchor middle
bad anchor "middle": must be n, ne, e, se, s, sw, w, nw, or center
-errorcode TCL LOOKUP INDEX anchor middle-aspect PERCENT
The ratio of the width to the height of the text, in percent.
With -width 0, the message breaks its text into lines so that 100 times the width divided by the height is near this value. 150 makes the text one and a half times as wide as it is tall.

-aspect 50
-aspect 150
-aspect 400-text A note that is long enough to wrap.# A larger aspect gives a wider message.
% message .aspect -text "one two three four five six seven eight"
> message .aspectwide -text "one two three four five six seven eight" -aspect 400
> expr {[winfo reqwidth .aspectwide] > [winfo reqwidth .aspect]}
1% message .aspect2 -aspect x
expected integer but got "x"
-errorcode TCL VALUE NUMBER-background COLOR
The background color of the message.
The color behind the content. -bg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

-background {#fde68a}
-background {#bfdbfe}-text Note.% message .background -background {#336699}
> .background cget -background
#336699% message .background2 -background nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-borderwidth DISTANCE
The width of the border of the message.
The width of the border around the message. -bd is the same option. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.

-borderwidth 0
-borderwidth 1
-borderwidth 4-text Note -relief solid.% message .borderwidth -borderwidth 4
> .borderwidth cget -borderwidth
4% message .borderwidth2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS-cursor CURSOR
The shape of the pointer over the message.
Each value side by side: the contact sheet of the cursors
A cursor name of Tk, such as hand2 or xterm. A value that starts with @ names a file. An empty value uses the cursor of the parent.
% message .cursor -cursor hand2
> .cursor cget -cursor
hand2% message .cursor2 -cursor nocursor
bad cursor spec "nocursor"
-errorcode TK VALUE CURSOR-font FONT
The font of the text.
A font name, such as TkDefaultFont, or a font description, such as {Helvetica 12 bold}. A family that does not exist falls back to a font of the system.

-font TkDefaultFont
-font TkFixedFont
-font {Helvetica 16 bold}-text Note.% message .font -font {Helvetica 12 bold}
> .font cget -font
Helvetica 12 bold% message .font2 -font {Helvetica big}
expected integer but got "big"
-errorcode TCL VALUE NUMBER-foreground COLOR
The color of the text.
The color of the text. -fg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

-foreground {#b91c1c}
-foreground {#2563eb}-text Note.% message .foreground -foreground {#336699}
> .foreground cget -foreground
#336699% message .foreground2 -foreground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightbackground COLOR
The color of the focus ring while the message has no focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the message does not have the focus. ztk stores the value with no effect.
% message .highlightbackground -highlightbackground {#336699}
> .highlightbackground cget -highlightbackground
#336699% message .highlightbackground2 -highlightbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightcolor COLOR
The color of the focus ring while the message has the focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the message has the focus. ztk stores the value with no effect.
% message .highlightcolor -highlightcolor {#336699}
> .highlightcolor cget -highlightcolor
#336699% message .highlightcolor2 -highlightcolor nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightthickness DISTANCE
The width of the focus ring, in the look of Tk on X11.
The width of the ring around the message that shows the focus. The modern theme draws the focus with the stylesheet.
% message .highlightthickness -highlightthickness 4
> .highlightthickness cget -highlightthickness
4% message .highlightthickness2 -highlightthickness x
bad screen distance "x"
-errorcode TK VALUE PIXELS-justify SIDE
The alignment of the lines of the text.
How the lines of the text line up with each other: at the left, in the middle, or at the right.
Values: left, right, center.

-justify left
-justify center
-justify right-text Short
A longer line.% message .justify -justify right
> .justify cget -justify
right% message .justify2 -justify middle
bad justification "middle": must be left, right, or center
-errorcode TCL LOOKUP INDEX justification middle-padx DISTANCE
The space at the left and the right of the content.
The space between the text and the left and the right sides. The default -1 leaves the padding to the theme, and a value of the script replaces it.

-padx 1
-padx 4
-padx 16-text Note.% message .padx -padx 4
> .padx cget -padx
4% message .padx2 -padx x
bad screen distance "x"
-errorcode TK VALUE PIXELS-pady DISTANCE
The space above and below the content.
The space between the text and the top and the bottom. The default -1 leaves the padding to the theme, and a value of the script replaces it.

-pady 1
-pady 2
-pady 10-text Note.% message .pady -pady 4
> .pady cget -pady
4% message .pady2 -pady x
bad screen distance "x"
-errorcode TK VALUE PIXELS-relief RELIEF
The 3-D look of the border.
Each value side by side: the contact sheet of the reliefs
The style of the border: raised and sunken look 3-D, and groove and ridge are lines. The theme draws the border, and the CSS of the theme can give a relief its own look with border-style.
Values: flat, groove, raised, ridge, solid, sunken.

-relief flat
-relief raised
-relief sunken
-relief groove
-relief ridge
-relief solid-text Note -borderwidth 4.% message .relief -relief groove
> .relief cget -relief
groove% message .relief2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy-takefocus TEXT
Whether the Tab key can move the focus to the message.
1 puts the message in the order of the Tab key, and 0 leaves it out. An empty value uses the default rule of Tk for the widget. In Tk the value can also be a script, and its result is the answer. ztk stores each value with no check.
% message .takefocus -takefocus 1
> .takefocus cget -takefocus
1ztk stores each value of the option with no check.
-text TEXT
The text of the message.
The text that the message shows. The message breaks the text at spaces into lines, and a newline starts a new line.

-text Note
-text {A longer note}% message .text -text Save
> .text cget -text
SaveEach string is a valid text.
-textvariable VAR
A global variable whose value is the text of the message.
The message shows the value of the global variable VAR, and changes its text when the variable changes.
% message .textvariable -textvariable v
> .textvariable cget -textvariable
vEach name is a valid variable name.
-width DISTANCE
The length of the lines of the text.
With a value more than 0, the message breaks its text into lines of at most this length, and -aspect has no effect. 0 uses -aspect.

-width 0
-width 60
-width 120-text A note that is long enough to wrap.% message .width -text "one two three four five six" -width 60
> update
> winfo reqwidth .width
60% message .width2 -width x
bad screen distance "x"
-errorcode TK VALUE PIXELSReturns
PATHNAME.
Examples
% message .note -text "The file has changes that are not saved. Save them before you close the window?"
> .note cget -aspect
150
% winfo class [message .go]
Message
Errors
% message .x -foo 1
unknown option "-foo"
-errorcode TK LOOKUP OPTION -foo
% message .twice
> message .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% message .no.b
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% message
wrong # args: should be "message pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
- The fonts and the padding of the theme differ from Tk, so the size of a message and its lines differ from Tk 8.6.16.
-highlightbackgroundand-highlightcolorare stored with no effect.- The theme gives the border, so the default
-borderwidthis 0. In Tk 8.6.16 it is 1.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1