GUI Programming With Python - Message Widget in Tkinter
GUI Programming With Python - Message Widget in Tkinter
TKINTER
MESSAGE WIDGET
Let's have a look at a simple example. The following script creates a message with a famous saying by
Mahatma Gandhi:
If you want to run this script under Python3, the only thing you have to change is the import line. Instead of
http://www.python-course.eu/tkinter_message_widget.php 1/3
10/7/2014 GUI Programming with Python: Message widget in Tkinter
Option Meaning
anchor The position, where the text should be placed in the message widget: N, NE, E,
SE, S, SW, W, NW, or CENTER. The Default is CENTER.
aspect Aspect ratio, given as the width/height relation in percent. The default is 150,
which means that the message will be 50% wider than it is high. Note that if the
width is explicitly set, this option is ignored.
background The background color of the message widget. The default value is system
specific.
cursor Defines the kind of cursor to show when the mouse is moved over the message
widget. By default the standard cursor is used.
fg Same as foreground.
highlightbackground Together with highlightcolor and highlightthickness, this option controls how to
draw the highlight region.
justify Defines how to align multiple lines of text. Use LEFT, RIGHT, or CENTER.
Note that to position the text inside the widget, use the anchor option. Default is
LEFT.
relief Border decoration. The default is FLAT. Other possible values are SUNKEN,
RAISED, GROOVE, and RIDGE.
takefocus If true, the widget accepts input focus. The default is false.
text Message text. The widget inserts line breaks if necessary to get the requested
aspect ratio. (text/Text)
textvariable Associates a Tkinter variable with the message, which is usually a StringVar. If
http://www.python-course.eu/tkinter_message_widget.php 2/3
10/7/2014 GUI Programming with Python: Message widget in Tkinter
width Widget width given in character units. A suitable width based on the aspect
setting is automatically chosen, if this option is not given.
© 2011 - 2014 Bernd Klein, Bodenseo; Design by Denise Mitchinson adapted for python-course.eu by Bernd Klein
http://www.python-course.eu/tkinter_message_widget.php 3/3