1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

feat(core): introduce Text.format_parametrized()

This commit is contained in:
Martin Milata 2020-12-15 11:45:58 +01:00
parent f1382bf892
commit 18cb429610

View File

@ -405,6 +405,22 @@ class TextBase(ui.Component):
def br_half(self) -> None:
self.content.append(BR_HALF)
def format_parametrized(
self,
format_string: str,
*params: str,
font: int = ui.NORMAL,
param_font: int = ui.BOLD,
) -> None:
parts = format_string.split("{}", len(params))
for i in range(len(parts)):
self.content.append(font)
self.content.append(parts[i].strip(" "))
if i < len(parts) - 1 and i < len(params):
param = params[i]
self.content.append(param_font)
self.content.append(param)
def on_render(self) -> None:
pass