tkinter.Label

SYNOPSIS

instance = tkinter.Label(parent ,**options)

STANDARD OPTIONS

activebackground
activeforeground
anchor
background
bitmap
borderwidth
compound
cursor
disabledforeground
font
foreground
highlightbackground
highlightcolor
highlightthickness
image
justify
padx
pady
relief
takefocus
text
textvariable
underline
wraplength

WIDGET-SPECIFIC OPTIONS

height
Specifies a desired height for the label. If an image or bitmap is being displayed in the label then the value is in screen units; for text it is in lines of text. If this option is not specified, the label's desired height is computed from the size of the image or bitmap or text being displayed in it.

state
Specifies one of three states for the label: "normal", "active", or "disabled". In "normal" state the button is displayed using the foreground and background options. In "active" state the label is displayed using the activeforeground and activebackground options. In the "disabled" state the disabledforeground and background options determine how the button is displayed.

width
Specifies a desired width for the label. If an image or bitmap is being displayed in the label then the value is in screen units; for text it is in characters. If this option is not specified, the label's desired width is computed from the size of the image or bitmap or text being displayed in it.

DESCRIPTION

A label is a widget that displays a textual string, bitmap or image. If text is displayed, it must all be in a single font, but it can occupy multiple lines on the screen (if it contains newlines or if wrapping occurs because of the wraplength option) and one of the characters may optionally be underlined using the underline option. The label can be manipulated in a few simple ways, such as changing its relief or text, using the commands described below.

WIDGET COMMAND

instance.cget("option")
Returns the current value of the configuration option given by "option". Option may have any of the values accepted by the Label class.

instance.configure()
instance.configure("option")
instance.configure(**options)
Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for instance: the elements of the list are the option name, database name, database class, default value, and current value.
If “option” is specified, then the method returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).
If **options are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the method returns an empty string. Option may have any of the values accepted by the Label class.

BINDINGS

When a new label is created, it has no default event bindings: Labels are not intended to be interactive.

EXAMPLE

# Import tkinter’s module
import tkinter

# Make the root widget
root = tkinter.Tk()

# Make the widgets
t = tkinter.Label(root ,text="This Widget is at the top", bg="red")
b = tkinter.Label(root ,text="This Widget is at the bottom", bg="green")
l = tkinter.Label(root ,text="Left\nHand\nSide")
r = tkinter.Label(root ,text="Right\nHand\nSide")
mid = tkinter.Text(root)
mid.insert(tkinter.END ,"This layout is like Java's BorderLayout")

# Lay them out
t.pack(side=tkinter.TOP ,fill=tkinter.X)
b.pack(side=tkinter.BOTTOM ,fill=tkinter.X)
l.pack(side=tkinter.LEFT ,fill=tkinter.Y)
r.pack(side=tkinter.RIGHT ,fill=tkinter.Y)
mid.pack(expand=1 ,fill=tkinter.BOTH)

root.mainloop()

label exemple