Tkinter Message Handling text parameters with string variables
Tkinter Message Handling text parameters with string variables Example#1
Handles the text inside Message() as a string variable.
from tkinter import *
root = Tk()
root.title("apidemos.com")
var = StringVar()
msg = Message(root,textvariable=var,relief=RAISED)
var.set(
"""apidemos.com provides tutorials on the basics of programming, introducing the basics of various programming languages such as HTML, CSS, Javascript, Python, Java, Ruby, C, PHP , MySQL and more. The site also provides a large number of online examples, through the examples, you can better learn programming..."""
)
msg.pack(padx=10,pady=10)
root.mainloop()
Output:
Tkinter Message Handling text parameters with string variables Example#2
Expand the above example by setting the background to yellow.
from tkinter import *
root = Tk()
root.title("apidemos.com")
var = StringVar()
msg = Message(root,textvariable=var,relief=RAISED,font="times 30 italic")
var.set(
"""apidemos.com provides tutorials on the basics of programming, introducing the basics of various programming languages such as HTML, CSS, Javascript, Python, Java, Ruby, C, PHP , MySQL and more. The site also provides a large number of online examples, through the examples, you can better learn programming..."""
)
msg.config(bg="yellow")
msg.pack(padx=10,pady=10)
root.mainloop()
Output: