def executionResultBox(streams, exception, resultInTuple,
                       bUseDefaultPerspecitveForException,
                       bUseDefaultPerspectiveForResult):
    boxContents = []
    for stream in streams:
        if stream.name == 'out':
            boxContents.append(
                execStdout(stream.richString, bUseDefaultPerspectiveForResult))
        elif stream.name == 'err':
            boxContents.append(
                execStderr(stream.richString, bUseDefaultPerspectiveForResult))
        else:
            raise ValueError, 'Unreckognised stream \'{0}\''.format(
                stream.name)
    if exception is not None:
        exceptionView = Pres.coerce(exception).alignHPack()
        if bUseDefaultPerspecitveForException:
            exceptionView = ApplyPerspective.defaultPerspective(exceptionView)
        boxContents.append(execException(exceptionView))
    if resultInTuple is not None:
        resultView = Pres.coercePresentingNull(resultInTuple[0]).alignHPack()
        if bUseDefaultPerspectiveForResult:
            resultView = ApplyPerspective.defaultPerspective(resultView)
        boxContents.append(execResult(resultView))

    if len(boxContents) > 0:
        return ApplyStyleSheetFromAttribute(ExecutionStyle.resultBoxStyle,
                                            Column(boxContents).alignHExpand())
    else:
        return None
def _richStringItem(item, textStyleAttribute, bUseDefaultPerspectiveForResult):
    if item.isStructural():
        resultView = Pres.coercePresentingNull(item.getValue())
        if bUseDefaultPerspectiveForResult:
            resultView = ApplyPerspective.defaultPerspective(resultView)
        return resultView
    else:
        return _textLines(item.getValue(), textStyleAttribute)