MCPcopy Create free account
hub / github.com/PageBot/PageBot / copy

Method copy

Lib/pagebot/elements/text.py:377–397  ·  view source on GitHub ↗

Answers a full copy of `self`, where the "unique" fields are set to default. Also performs a deep copy on all child elements. >>> from pagebot.toolbox.color import blackColor, noColor >>> from pagebot.toolbox.units import pt >>> from pagebot.contexts import getContex

(self, parent=None)

Source from the content-addressed store, hash-verified

375 self.drawMeta(view, origin)
376
377 def copy(self, parent=None):
378 """Answers a full copy of `self`, where the "unique" fields are set to
379 default. Also performs a deep copy on all child elements.
380
381 >>> from pagebot.toolbox.color import blackColor, noColor
382 >>> from pagebot.toolbox.units import pt
383 >>> from pagebot.contexts import getContext
384 >>> from pagebot.document import Document
385 >>> context = getContext()
386 >>> doc = Document(w=300, h=400, context=context)
387 >>> page = doc[1]
388 >>> style = dict(textFill=blackColor, textStroke=noColor)
389 >>> bs = context.newString('Hello world', style)
390 >>> t = Text(bs, name='Child', w=100, parent=page)
391 >>> copyE = t.copy() # Copy the element attribute, including the string of self.
392 >>> copyE.bs
393 $Hello worl...$
394 """
395 e = Element.copy(self, parent=parent)
396 e.bs = deepcopy(self.bs) # Copy the string separately.
397 return e
398
399 def append(self, bs, style=None):
400 """Appends to the current BabelString instance self.bs."""

Callers 2

initializeStylesMethod · 0.45
getNodeStyleMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected