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

Method makeRootStyle

Lib/pagebot/document.py:396–425  ·  view source on GitHub ↗

Creates a rootStyle, then set the arguments from keyword arguments, if their entry name already exists. This is similar to the makeStyle in Elements. >>> from pagebot.constants import BOTTOM, TOP >>> doc = Document() >>> page = doc[1] # Default inheriting from doc

(self, **kwargs)

Source from the content-addressed store, hash-verified

394 self.addStyle(name, dict(name=name))
395
396 def makeRootStyle(self, **kwargs):
397 """Creates a rootStyle, then set the arguments from keyword arguments,
398 if their entry name already exists. This is similar to the makeStyle in Elements.
399
400 >>> from pagebot.constants import BOTTOM, TOP
401 >>> doc = Document()
402 >>> page = doc[1] # Default inheriting from doc
403 >>> doc.rootStyle['yAlign'], page.yAlign
404 ('bottom', 'bottom')
405 >>> doc = Document(yAlign=TOP)
406 >>> page = doc[1] # Inheriting from doc
407 """
408
409 """
410 >>> doc.rootStyle['yAlign'], page.yAlign
411 ('top', 'top')
412 >>> doc = Document(yAlign=BOTTOM)
413 >>> page = doc[1] # Inheriting from doc, overwriting yAlign default.
414 >>> #doc.rootStyle['yAlign'], page.yAlign
415 #('bottom', 'bottom')
416 >>> doc = Document(yAlign=TOP)
417 >>> page = doc[1] # Inheriting from doc, overwriting yAlign default.
418 >>> doc.rootStyle['yAlign'], page.yAlign
419 ('top', 'top')
420 """
421 rootStyle = getRootStyle()
422 for name, v in kwargs.items():
423 if name in rootStyle: # Only overwrite existing values.
424 rootStyle[name] = v
425 return rootStyle
426
427 def applyStyle(self, style):
428 """Applies the key-value of the style onto the self.rootStyle. This

Callers 1

__init__Method · 0.95

Calls 1

getRootStyleFunction · 0.90

Tested by

no test coverage detected