(self, bs=None, w=None, h=None, size=None, style=None,
padding=None, xTextAlign=None, xAlign=None, yAlign=None,
margin=None, top=None, bottom=None, **kwargs)
| 56 | TEXT_MIN_WIDTH = 24 |
| 57 | |
| 58 | def __init__(self, bs=None, w=None, h=None, size=None, style=None, |
| 59 | padding=None, xTextAlign=None, xAlign=None, yAlign=None, |
| 60 | margin=None, top=None, bottom=None, **kwargs): |
| 61 | |
| 62 | # Placeholder, ignoring self.w and self.h until defined. |
| 63 | self._bs = None |
| 64 | |
| 65 | # Adjust the attributes in **kwargs, so their keys are part of the |
| 66 | # rootstyle, in order to do automatic conversion with makeStyle() |
| 67 | Element.__init__(self, **kwargs) |
| 68 | assert self.context |
| 69 | """Creates a Text element, holding storage of `self.bs`. |
| 70 | BabelString instance.""" |
| 71 | |
| 72 | # Combines rootStyle, optional self.style and **kwargs attributes. Note |
| 73 | # that the final style is stored in the BabelString instance self.bs. |
| 74 | # self.style is used as template, in the content is defined as plain |
| 75 | # string. |
| 76 | if style is not None: |
| 77 | #self.style = makeStyle(style, **kwargs) |
| 78 | self.style = makeStyle(style) |
| 79 | |
| 80 | # Set as property, to make sure there's always a generic BabelString |
| 81 | # instance or None. Needs to be done before element initialisation, |
| 82 | # because some attributes (Text.xTextAlign) may need the string style |
| 83 | # as reference. |
| 84 | self.bs = bs # BabelString source for this Text element. |
| 85 | |
| 86 | # TODO: shouldn't BabelString be required? |
| 87 | #assert self.bs |
| 88 | |
| 89 | # These need the self.bs to be defined. |
| 90 | if xTextAlign is not None: |
| 91 | self.xTextAlign = xTextAlign |
| 92 | |
| 93 | if xAlign is not None: |
| 94 | self.xAlign = xAlign |
| 95 | if yAlign is not None: |
| 96 | self.yAlign = yAlign |
| 97 | else: |
| 98 | self.yAlign = BOTTOM |
| 99 | |
| 100 | if padding is not None: |
| 101 | self.padding = padding |
| 102 | if margin is not None: |
| 103 | self.margin = margin |
| 104 | if top is not None: |
| 105 | self.top = top |
| 106 | if bottom is not None: |
| 107 | self.bottom = bottom |
| 108 | |
| 109 | self.w = w |
| 110 | self.h = h |
| 111 | |
| 112 | def _get_bs(self): |
| 113 | """Answers the stored formatted BabelString. The value can be None.""" |
nothing calls this directly
no test coverage detected