Reduce the calls to Text when building the button

Found out that Text.assemble can take a collection of tuple of text and
style, which makes things a lot easier and needs less object construction.
This commit is contained in:
Dave Pearson
2023-02-23 10:06:13 +00:00
parent 177aae6902
commit a32a9fa6af

View File

@@ -151,9 +151,9 @@ class ToggleButton(Static, can_focus=True):
) )
return Text.assemble( return Text.assemble(
Text(self.BUTTON_LEFT, style=side_style), (self.BUTTON_LEFT, side_style),
Text(self.BUTTON_INNER, style=button_style), (self.BUTTON_INNER, button_style),
Text(self.BUTTON_RIGHT, style=side_style), (self.BUTTON_RIGHT, side_style),
) )
def render(self) -> RenderResult: def render(self) -> RenderResult: