Source code for carbonkivy.uix.label.label
from __future__ import annotations
__all__ = (
"CBaseLabel",
"CLabel",
"CLabelCircular",
)
from kivy.properties import NumericProperty, OptionProperty
from kivy.uix.label import Label
from carbonkivy.behaviors import (
AdaptiveBehavior,
BackgroundColorBehaviorCircular,
BackgroundColorBehaviorRectangular,
DeclarativeBehavior,
)
from carbonkivy.theme.size_tokens import font_style_tokens
[docs]
class CBaseLabel(AdaptiveBehavior, DeclarativeBehavior, Label):
[docs]
style = OptionProperty("body_compact_02", options=font_style_tokens.keys())
[docs]
typeface = OptionProperty(
"IBM Plex Sans", options=["IBM Plex Sans", "IBM Plex Serif", "IBM Plex Mono"]
)
[docs]
weight_style = OptionProperty(
"Regular",
options=[
"Bold",
"BoldItalic",
"ExtraLight",
"ExtraLightItalic",
"Italic",
"Light",
"LightItalic",
"Medium",
"MediumItalic",
"Regular",
"SemiBold",
"SemiBoldItalic",
"Thin",
"ThinItalic",
],
)
_font_size = NumericProperty(None, allownone=True)
def __init__(self, **kwargs) -> None:
super(CBaseLabel, self).__init__(**kwargs)
[docs]
def on_kv_post(self, base_widget):
self.canvas.remove_group("backgroundcolor-behavior-bg-color")
self.canvas.remove_group("Background_instruction")
return super().on_kv_post(base_widget)
[docs]
class CLabel(BackgroundColorBehaviorRectangular, CBaseLabel):
pass
[docs]
class CLabelNeutral(CLabel):
pass
[docs]
class CLabelCircular(
BackgroundColorBehaviorCircular,
CBaseLabel,
):
pass
[docs]
class CLabelNeutralCircular(CLabelCircular):
pass