Python Tkinter Message
The Message widget is used to show the message to the user regarding the behaviour of the python application. The message widget shows the text messages to the user which can not be edited.
The message text contains more than one line. However, the message can only be shown in the single font.
The syntax to use the Message widget is given below.
- w = Message(parent, options)
A list of possible options is given below.
|It is used to decide the exact position of the text within the space provided to the widget if the widget contains more space than the need of the text. The default is CENTER.
|The background color of the widget.
|It is used to display the graphics on the widget. It can be set to any graphical or image object.
|It represents the size of the border in the pixel. The default size is 2 pixel.
|The mouse pointer is changed to the specified cursor type. The cursor type can be an arrow, dot, etc.
|The font type of the widget text.
|The font color of the widget text.
|The vertical dimension of the message.
|We can set this option to a static image to show that onto the widget.
|This option is used to specify the alignment of multiple line of code with respect to each other. The possible values can be LEFT (left alignment), CENTER (default), and RIGHT (right alignment).
|The horizontal padding of the widget.
|The vertical padding of the widget.
|It represents the type of the border. The default type is FLAT.
|We can set this option to the string so that the widget can represent the specified text.
|This is used to control the text represented by the widget. The textvariable can be set to the text that is shown in the widget.
|The default value of this option is -1 that represents no underline. We can set this option to an existing number to specify that nth letter of the string will be underlined.
|It specifies the horizontal dimension of the widget in the number of characters (not pixel).
|We can wrap the text to the number of lines by setting this option to the desired number so that each line contains only that number of characters.
- from tkinter import *
- top = Tk()
- var = StringVar()
- msg = Message( top, text = “Welcome to Javatpoint”)