This article Reprinted from: http://blog.csdn.net/jcodeer/article/details/1811326
''' Tkinter message '''
# Message is used to display text. Its usage is basically the same as that of label.
'''1. Create a simple message '''
From tkinter import *
Root = TK ()
Message (root, text = 'Hello message'). Pack ()
Root. mainloop ()
# Run the program. After you see hello, the message is displayed in the next line. This is also a feature of message. No label.
'''2. If you do not want it to wrap, specify a sufficiently large width '''
From tkinter import *
Root = TK ()
Message (root, text = 'Hello message', width = 60). Pack ()
Root. mainloop ()
# Run the program. After you see hello, the message is displayed in the next line. This is also a feature of message. No label.
'''3. Use the aspect attribute to specify the width-to-height ratio '''
#-*-Coding: cp936 -*-
From tkinter import *
Root = TK ()
For I in range (10 ):
Message (root, text = 'A '* I, aspect = 400). Pack ()
Root. mainloop ()
# The default value is wider/Height = 1.5. You can use the aspect attribute and set it to 4, which is four times the width is high. 10 'A' values can be displayed'
''4message: bind the variable '''
#-*-Coding: cp936 -*-
From tkinter import *
Root = TK ()
V = stringvar ()
V. Set ('000 ')
For I in range (10 ):
Message (root, text = 'A', textvariable = V). Pack ()
# Print the current value of V. If the value of one of the messages changes, the value of V changes.
Print v. Get ()
Root. mainloop ()
# Bind the variable v. Although text is used to specify the message value during message creation, the bound variable has a high priority and can change the text
# The specified value.
'''5. Test the justify attribute '''
#-*-Coding: cp936 -*-
From tkinter import *
Root = TK ()
For I in [left, right, center]:
Message (root, text = 'abc def ghi', justify = I). Pack ()
Root. mainloop ()
# The displayed text is automatically disconnected. The upper and lower lines are left-aligned, right-aligned, and center-aligned respectively.
Message in tkinter tutorial