Inscription#
Added in version 4.8.
Superclasses: Widget, InitiallyUnowned, Object
Implemented Interfaces: Accessible, AccessibleText, Buildable, ConstraintTarget
Shows text in a predefined area.
You likely want to use GtkLabel instead as this widget is intended only
for a small subset of use cases. The main scenario envisaged is inside lists
such as GtkColumnView.
While a GtkLabel sizes itself depending on the text that is displayed,
GtkInscription is given a size and inscribes the given text into that
space as well as it can.
Users of this widget should take care to plan behaviour for the common case where the text doesn’t fit exactly in the allocated space.
CSS nodes#
GtkInscription has a single CSS node with the name label.
Constructors#
Methods#
- class Inscription
-
- get_min_chars() int#
Gets the
min-charsof the inscription.See the
min_charsproperty.Added in version 4.8.
- get_min_lines() int#
Gets the
min-linesof the inscription.See the
min_linesproperty.Added in version 4.8.
- get_nat_chars() int#
Gets the
nat-charsof the inscription.See the
nat_charsproperty.Added in version 4.8.
- get_nat_lines() int#
Gets the
nat-linesof the inscription.See the
nat_linesproperty.Added in version 4.8.
- get_text_overflow() InscriptionOverflow#
Gets the inscription’s overflow method.
Added in version 4.8.
- get_wrap_mode() WrapMode#
Returns line wrap mode used by the inscription.
See
set_wrap_mode.Added in version 4.8.
- get_xalign() float#
Gets the
xalignof the inscription.See the
xalignproperty.Added in version 4.8.
- get_yalign() float#
Gets the
yalignof the inscription.See the
yalignproperty.Added in version 4.8.
- set_attributes(attrs: AttrList | None = None) None#
Apply attributes to the inscription text.
These attributes will not be evaluated for sizing the inscription.
Added in version 4.8.
- Parameters:
attrs – a
AttrList
- set_markup(markup: str | None = None) None#
Utility function to set the text and attributes to be displayed.
See the
markupproperty.Added in version 4.8.
- Parameters:
markup – The markup to display
- set_min_chars(min_chars: int) None#
Sets the
min-charsof the inscription.See the
min_charsproperty.Added in version 4.8.
- Parameters:
min_chars – the minimum number of characters that should fit, approximately
- set_min_lines(min_lines: int) None#
Sets the
min-linesof the inscription.See the
min_linesproperty.Added in version 4.8.
- Parameters:
min_lines – the minimum number of lines that should fit, approximately
- set_nat_chars(nat_chars: int) None#
Sets the
nat-charsof the inscription.See the
nat_charsproperty.Added in version 4.8.
- Parameters:
nat_chars – the number of characters that should ideally fit, approximately
- set_nat_lines(nat_lines: int) None#
Sets the
nat-linesof the inscription.See the
nat_linesproperty.Added in version 4.8.
- Parameters:
nat_lines – the number of lines that should ideally fit
- set_text(text: str | None = None) None#
Sets the text to be displayed.
Added in version 4.8.
- Parameters:
text – The text to display
- set_text_overflow(overflow: InscriptionOverflow) None#
Sets what to do when the text doesn’t fit.
Added in version 4.8.
- Parameters:
overflow – the overflow method to use
- set_wrap_mode(wrap_mode: WrapMode) None#
Controls how line wrapping is done.
Added in version 4.8.
- Parameters:
wrap_mode – the line wrapping mode
Properties#
- class Inscription
- props.attributes: AttrList#
A list of style attributes to apply to the text of the inscription.
Added in version 4.8.
- props.markup: str#
Utility property that sets both the
textandattributesproperties, mainly intended for use in GtkBuilder ui files to ease translation support and bindings.This function uses
parse_markupto parse the markup into text and attributes. The markup must be valid. If you cannot ensure that, consider usingparse_markupand setting the two properties yourself.Added in version 4.8.
- props.min_chars: int#
The number of characters that should fit into the inscription at minimum.
This influences the requested width, not the width actually given to the widget, which might turn out to be larger.
Note that this is an approximate character width, so some characters might be wider and some might be thinner, so do not expect the number of characters to exactly match.
If you set this property to 0, the inscription will not request any width at all and its width will be determined entirely by its surroundings.
Added in version 4.8.
- props.min_lines: int#
The number of lines that should fit into the inscription at minimum.
This influences the requested height, not the height actually given to the widget, which might turn out to be larger.
Note that this is an approximate line height, so if the text uses things like fancy Unicode or attribute that influence the height, the text might not fit.
If you set this property to 0, the inscription will not request any height at all and its height will be determined entirely by its surroundings.
Added in version 4.8.
- props.nat_chars: int#
The number of characters that should ideally fit into the inscription.
This influences the requested width, not the width actually given to the widget. The widget might turn out larger as well as smaller.
If this property is set to a value smaller than
min_chars, that value will be used. In particular, for the default value of 0, this will always be the case.Added in version 4.8.
- props.nat_lines: int#
The number of lines that should ideally fit into the inscription.
This influences the requested height, not the height actually given to the widget. The widget might turn out larger as well as smaller.
If this property is set to a value smaller than
min_lines, that value will be used. In particular, for the default value of 0, this will always be the case.Added in version 4.8.
- props.text_overflow: InscriptionOverflow#
The overflow method to use for the text.
Added in version 4.8.
- props.wrap_mode: WrapMode#
Controls how the line wrapping is done.
Note that unlike
GtkLabel, the default here is %PANGO_WRAP_WORD_CHAR.Added in version 4.8.