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)
| 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 |
no test coverage detected