SourceClass RichText
from egui import RichTextclass RichText:Text and optional style choices for it.
The style choices (font, color) are applied to the entire text.
For more detailed control, use egui.text.LayoutJob instead.
A RichText can be used in most widgets and helper functions, e.g. Ui.label and Ui.button.
Example
Methods§
Sourcedef append_to(self, /, layout_job: LayoutJob, style: Style, fallback_font: FontSelection |None = None, default_valign: Align |None = None) -> None§
Sourcedef background_color(self, /, color: Color32) -> RichText§
Fill-color behind the text.
Sourcedef code(self, /) -> RichText§
Monospace label with different background color.
Sourcedef color(self, /, color: Color32) -> RichText§
Override text color.
If not set, Color32.PLACEHOLDER will be used,
which will be replaced with a color chosen by the widget that paints the text.
Sourcedef extra_letter_spacing(self, /, extra_letter_spacing: float) -> RichText§
Extra spacing between letters, in points.
Default: 0.0.
For even text it is recommended you round this to an even number of pixels,
e.g. using emath.GuiRounding.
Sourcedef fallback_text_style(self, /, text_style: TextStyle) -> RichText§
Set the TextStyle unless it has already been set
Sourcedef family(self, /, family: FontFamily) -> RichText§
Select the font family.
This overrides the value from egui.RichText.text_style.
Only the families available in egui.FontDefinitions.families may be used.
Sourcedef font(self, /, font_id: FontId) -> RichText§
Select the font and size.
This overrides the value from egui.RichText.text_style.
Sourcedef font_height(self, /, ctx: Context, style: Style) -> float§
Read the font height of the selected text style.
Returns a value rounded to emath.GUI_ROUNDING.
Sourcedef heading(self, /) -> RichText§
Use TextStyle.Heading.
def into_widget_text(self, /) -> WidgetText§
Sourcedef is_empty(self, /) -> bool§
Sourcedef italics(self, /) -> RichText§
Tilt the characters to the right.
Sourcedef line_height(self, /, line_height: float |None) -> RichText§
Explicit line height of the text in points.
This is the distance between the bottom row of two subsequent lines of text.
If None (the default), the line height is determined by the font.
For even text it is recommended you round this to an even number of pixels,
e.g. using emath.GuiRounding.
Sourcedef monospace(self, /) -> RichText§
Use TextStyle.Monospace.
Sourcedef raised(self, /) -> RichText§
Align text to top. Only applicable together with egui.RichText.small().
Sourcedef size(self, /, size: float) -> RichText§
Select the font size (in points).
This overrides the value from egui.RichText.text_style.
Sourcedef small(self, /) -> RichText§
Smaller text.
Sourcedef small_raised(self, /) -> RichText§
For e.g. exponents.
Sourcedef strikethrough(self, /) -> RichText§
Draw a line through the text, crossing it out.
If you want to control the strikethrough line color, use LayoutJob instead.
Sourcedef strong(self, /) -> RichText§
Extra strong text (stronger color).
Sourcedef text(self, /) -> str§
Sourcedef text_style(self, /, text_style: TextStyle) -> RichText§
Override the TextStyle.
Sourcedef underline(self, /) -> RichText§
Draw a line under the text.
If you want to control the line color, use LayoutJob instead.
Sourcedef variation(self, /, tag: str, coord: float) -> RichText§
Add a variation coordinate.
Sourcedef variations(self, /, variations: Sequence[tuple[str, float]]) -> RichText§
Override the variation coordinates completely.
Sourcedef weak(self, /) -> RichText§
Extra weak text (fainter color).