tkinter.Label(text)


Definition
The option display the text in Label.

Syntax
Label(master, text=string)

Examples
The frame "<ButtonRelease>" trigger the function(buttonrelease) which displays the Label(welcome).
from tkinter import *

master = Tk()

def buttonrelease(click):
    label=Label(frame, text="Welcome", fg="Blue")
    label.pack(side=TOP)

frame = Frame(master, background="blue", width=200, height=200)
frame.bind("<ButtonRelease>", buttonrelease)
frame.pack()

master.mainloop()









The button command function is used to invoke the message box to display the random value.
from tkinter import*

master = Tk()
master.title("Random Widget")

def random_value():
    import random
    random1=random.random()
    messagebox.showinfo("Random Value is", random1)

labelframe=LabelFrame(master, fg="red", font=14, text="Random value generator")
labelframe.pack(side=BOTTOM)

button = Button(labelframe, text = "Click here", fg="blue", command = random_value)
button.pack(side=BOTTOM)

label = Label(labelframe, text = "Click on button to generate random value")
label.pack(side=BOTTOM)

master.mainloop()





Comments