Web Analytics Made Easy - Statcounter
Skip to content

Text

Text - Display some text in the window. Usually this means a single line of text. However, the text can also be multiple lines. If multi-lined there are no scroll bars.

Text(
    text = "",
    size = (None, None),
    auto_size_text = None,
    click_submits = None,
    enable_events = False,
    relief = None,
    border_width = None,
    font = None,
    text_color = None,
    background_color = None,
    justification = None,
    pad = None,
    margins = None,
    key = None,
    tooltip = None,
    visible = True,
    size_px = (None, None)
)

Parameter Descriptions

Name Type Default Description
auto_size_text bool None if True size of the Text Element will be sized to fit the string provided in 'text' parm
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
border_width int None number of pixels for the border (if using a relief)
click_submits bool None DO NOT USE. Only listed for backwards compat - Use enable_events instead
enable_events bool False Turns on the element specific events. Text events happen when the text is clicked
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
justification str None how string should be aligned within space provided by size. Valid choices = left, right, center
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
margins (int, int) None (left/right, top/bottom) tkinter margins around outsize. Amount of pixels to leave inside the window's frame around the edges before your elements are shown.
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
relief (str/enum) None relief style around the text. Values are same as progress meter relief values. Should be a constant that is defined at starting with "RELIEF_" - RELIEF_RAISED, RELIEF_SUNKEN, RELIEF_FLAT, RELIEF_RIDGE, RELIEF_GROOVE, RELIEF_SOLID
size (int, int) or (None, None) (None, None) (w, h) w=characters-wide, h=rows-high
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
text Any The text to display. Can include /n to achieve multiple lines. Will convert (optional) parameter into a string
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
tooltip str None text, that will appear when mouse hovers over the element
visible bool True set visibility state of the element

Class Properties

This class has no public properties

Class Methods

 def update

update

Changes some of the settings for the Text Element. Must call Window.Read or Window.Finalize prior

Changes will not be visible in your window until you call window.read or window.refresh.

If you change visibility, your element may MOVE.

update(
    value = None,
    background_color = None,
    text_color = None,
    font = None,
    visible = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
value Any None new text to show
visible bool None set visibility state of the element