element_create(elementname, etype, *args, **kw)

Create a new element in the current theme, of the given etype which is expected to be either “image”, “from” or “vsapi”. The latter is only available in Tk 8.6a for Windows XP and Vista and is not described here.

If “image” is used, args should contain the default image name followed by statespec/value pairs (this is the imagespec), and kw may have the following options:

  • border=padding

    padding is a list of up to four integers, specifying the left, top, right, and bottom borders, respectively.

  • height=height

    Specifies a minimum height for the element. If less than zero, the base image’s height is used as a default.

  • padding=padding

    Specifies the element’s interior padding. Defaults to border’s value if not specified.

  • sticky=spec

    Specifies how the image is placed within the final parcel. spec contains zero or more characters “n”, “s”, “w”, or “e”.

  • width=width

    Specifies a minimum width for the element. If less than zero, the base image’s width is used as a default.

If “from” is used as the value of etype, element_create() will clone an existing element. args is expected to contain a themename, from which the element will be cloned, and optionally an element to clone from. If this element to clone from is not specified, an empty element will be used. kw is discarded.

Related Reading

tkinter.ttk — Tk themed widgets