Python Tkinter Message

In this tutorial, we will learn about Python Tkinter MessagePython Tkinter Message works same as Lable expect it can automatically wrap up content and given width. We mainly use this widget to show the multiline text.

Syntax to add Python Tkinter Message:

w = Message (master, options)
  • master: This represents the parent window.
  • options: Here is the list of most commonly used options for this widget.

Example Program of Python Tkinter Message:

from tkinter import *  
 
mainWindow = Tk()  

mainWindow.geometry("300x150")

text = StringVar()

text.set("Hello, Welcome to Owlbuddy")

label = Message( mainWindow, textvariable=text, relief=RAISED )

label.pack()

mainWindow.mainloop() 

Various possible options in Python Tkinter Message:

Option Description
anchor This option is used to set the position of text in widget The default is anchor=CENTER.
bg This option helps us to set the normal background colour of the widget.
bitmap This option helps us to display an image. You just have to set this option equal to an image object.
bd This option is used to set the size of the border around the widget.
cursor This option helps us to set the style of cursor like an arrow, dot etc
font This option is used to set font type in the widget.
fg This option helps us to set the normal foreground colour of the widget.
height This option helps us to set the height of the widget.
image This option helps us to show the image with the radio button instead of text.
justify This helps us to automatically organize the text in multiple lines.
padx This option helps us to set the space left and right.
pady This option helps us to set space above and below.
relief This helps us to set the style of the border by which is default Flat.
text This option helps us to set a string source for the label.
textvariable This option is used to mention text source(variable.)
underline This option helps us to underline the specified letter of the text.
width This helps us to set the width of the widget.
wraplength This option is used to wrap text into the number of lines.
Spread the love
Scroll to Top
×