i3pyblocks.utils¶
Module Contents¶
Functions¶
|
Helper to generate Pango markup for text. |
|
Wrapper for Python’s < 3.7 similar to asyncio.run(). |
-
i3pyblocks.utils.pango_markup(text: str, tag: str = 'span', **attrib) → str¶ Helper to generate Pango markup for text.
This helper makes it easier to generate Pango markup for arbitrary text, allowing for greater customization of text than the default attributes offered by i3bar protocol.
Simple usage:
>>> pango_markup("Hello, world!", font_weight="bold") '<span font_weight="bold">Hello, world!</span>'
It can also generate markups for other tags supported in Pango:
>>> pango_markup("Italic text", tag="i") '<i>Italic text</i>'
Keep in mind that there is no checks if your code is correct, so you can pass completely nonsense attributes/tags that will be ignored by Pango:
>>> pango_markup("Spam", foo="bar") '<span foo="bar">Spam</span>'
- Parameters
text – Text to be put inside the tag.
tag – XML tag that will be generated. By default it is
<span>.**attrib – Arbitrary attributes that will be added to tag.
See also
Look at https://developer.gnome.org/pango/stable/pango-Markup.html for information about the available tags and attributes.
-
i3pyblocks.utils.asyncio_run(awaitable: Awaitable, *, debug: bool = False) → Any¶ Wrapper for Python’s < 3.7 similar to asyncio.run().
In Python >= 3.7 this function simple calls asyncio.run(), but in older Python versions this function will try to simulate its functionality, the best way it can with the available public API of asyncio.
If you’re going to only use your configuration in Python 3.7+, I recommend skipping this function and using asyncio.run() directly,