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

Method css

Lib/pagebot/elements/element.py:1514–1536  ·  view source on GitHub ↗

In case we are looking for a plain css value, cascading from the main ancestor styles of self, then follow the parent links until document or root, if self does not contain the requested value. >>> from pagebot.toolbox.units import em >>> from pagebot.document import

(self, name, default=None)

Source from the content-addressed store, hash-verified

1512 # until style value is defined.
1513
1514 def css(self, name, default=None):
1515 """In case we are looking for a plain css value, cascading from the
1516 main ancestor styles of self, then follow the parent links until
1517 document or root, if self does not contain the requested value.
1518
1519 >>> from pagebot.toolbox.units import em
1520 >>> from pagebot.document import Document
1521 >>> doc = Document()
1522 >>> page = doc[1]
1523 >>> e = Element(fontSize=pt(24), parent=page)
1524 >>> e.css('fontSize') # Find local style value
1525 24pt
1526 >>> e.css('leading') # Find value in root style. Default is absolute unit. Can be changed to em.
1527 1.4em
1528 >>> e = Element(fontSize=pt(24), leading=em(1.4))
1529 >>> e.css('leading'), round(e.css('leading').pt) # Show unit and rendered compared to
1530 (1.4em, 17)
1531 """
1532 if name in self.style and self.style[name] is not None:
1533 return self.style[name]
1534 if self.parent is not None:
1535 return self.parent.css(name, default)
1536 return default
1537
1538 def checkStyleArgs(self, d):
1539 """Fix style values where necessary.

Callers 15

_get_isLockedMethod · 0.95
getFlattenedStyleMethod · 0.95
_get_emMethod · 0.95
_get_fontMethod · 0.95
_get_leadingMethod · 0.95
_get_trackingMethod · 0.95
_get_gridXMethod · 0.95
_get_gridYMethod · 0.95
_get_gridZMethod · 0.95
_get_cwMethod · 0.95
_get_chMethod · 0.95
_get_frontMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected