Python 3 tkinter Message Widget Program Examples

By | March 24, 2020

Topic: Python 3 tkinter Message Widget Program Examples

What is a Message Widget

The Message widget is specially designed to show multiline non-editable messages. The message widget will adjust its width. It can wrap text too. It uses a single font to display a multiline message.

Why and When to use the Message Widget

We may use the message widget to display short text messages on multiple lines, using a single font.

Here is an example of a Python 3 GUI program to display a multiline colorful message on main window. It uses a message widget with some of its options like font, fore ground and back ground color, padx, pady, relief = GROOVE border decoration etc.

Python 3 tkinter Message widget GUI Program Examples

Python 3 tkinter Message widget GUI Program Examples

from tkinter import *

def main():
    main_window = Tk()

    main_window.title('Message')
    str_quote = "Real friends are hard to find, difficult to leave and impossible to forget."
    msg = Message(main_window, text = str_quote,
                 padx=20, pady=20, bd=5, relief = GROOVE)
    msg.config(bg='green', fg='white', font=('verdana', 30))
    msg.pack()
    mainloop()

main()

Another simple GUI program example to show a message using Message Widget on multiple lines.

from tkinter import *

def main():
    master_window = Tk()

    str1="A Message for Python Programming Lovers"

    multiline_msg = Message(master_window,text=str1)
    multiline_msg.pack()

    mainloop()

main()    
Python 3 tkinter GUI Message Widget Programs

Python 3 tkinter GUI Message Widget Programs

One thought on “Python 3 tkinter Message Widget Program Examples

  1. Pingback: Find Factorial by Recursive Function Python GUI Program | EasyCodeBook.com

Leave a Reply

Your email address will not be published. Required fields are marked *