(etype, script=False, *args, **kw)
return spec, opts
Formats args and kw according to the given element factory etype.
Formats args and kw according to the given element factory etype.
Formats args and kw according to the given element factory etype .
def _format_elemcreate(etype, script=False, *args, **kw):
    """Formats args and kw according to the given element factory etype."""
    spec = None
    opts = ()
    if etype in ("image", "vsapi"):
        if etype == "image": # define an element based on an image
            # first arg should be the default image name
            iname = args[0]
            # next args, if any, are statespec/value pairs which is almost
            # a mapdict, but we just need the value
            imagespec = _join(_mapdict_values(args[1:]))
            spec = "%s %s" % (iname, imagespec)

        else:
            # define an element whose visual appearance is drawn using the
            # Microsoft Visual Styles API which is responsible for the
            # themed styles on Windows XP and Vista.
            # Availability: Tk 8.6, Windows XP and Vista.
            class_name, part_id = args[:2]
            statemap = _join(_mapdict_values(args[2:]))
            spec = "%s %s %s" % (class_name, part_id, statemap)

        opts = _format_optdict(kw, script)

    elif etype == "from": # clone an element
        # it expects a themename and optionally an element to clone from,
        # otherwise it will clone {} (empty element)
        spec = args[0] # theme name
        if len(args) > 1: # elementfrom specified
            opts = (_format_optvalue(args[1], script),)

    if script:
        spec = '{%s}' % spec
        opts = ' '.join(opts)

    return spec, opts
def _format_elemcreate ( etype , script = False , * args , * * kw ) : spec = None opts = ( ) if etype in ( "image" , "vsapi" ) : if etype == "image" : # define an element based on an image # first arg should be the default image name iname = args [ 0 ] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value imagespec = _join ( _mapdict_values ( args [ 1 : ] ) ) spec = "%s %s" % ( iname , imagespec ) else : # define an element whose visual appearance is drawn using the # Microsoft Visual Styles API which is responsible for the # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name , part_id = args [ : 2 ] statemap = _join ( _mapdict_values ( args [ 2 : ] ) ) spec = "%s %s %s" % ( class_name , part_id , statemap ) opts = _format_optdict ( kw , script ) elif etype == "from" : # clone an element # it expects a themename and optionally an element to clone from, # otherwise it will clone {} (empty element) spec = args [ 0 ] # theme name if len ( args ) > 1 : # elementfrom specified opts = ( _format_optvalue ( args [ 1 ] , script ) , ) if script : spec = '{%s}' % spec opts = ' ' . join ( opts ) return spec , opts