Skip to content

Gtk.CellRendererText

class — extends CellRenderer

:::warning Deprecated since 4.10 This API is deprecated. :::

Renders text in a cell

A GtkCellRendererText renders a given text in its cell, using the font, color and style information provided by its properties. The text will be ellipsized if it is too long and the GtkCellRendererText:ellipsize property allows it.

If the GtkCellRenderer:mode is CellRendererMode.EDITABLE, the GtkCellRendererText allows to edit its text using an entry.

Constructors

new

@classmethod
def new(cls) -> CellRenderer

:::warning Deprecated since 4.10 This API is deprecated. :::

Creates a new GtkCellRendererText. Adjust how text is drawn using object properties. Object properties can be set globally (with g_object_set()). Also, with GtkTreeViewColumn, you can bind a property to a value in a GtkTreeModel. For example, you can bind the “text” property on the cell renderer to a string value in the model, thus rendering a different string in each row of the GtkTreeView.

Methods

set_fixed_height_from_font

def set_fixed_height_from_font(self, number_of_rows: int) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets the height of a renderer to explicitly be determined by the “font” and “y_pad” property set on it. Further changes in these properties do not affect the height, so they must be accompanied by a subsequent call to this function. Using this function is inflexible, and should really only be used if calculating the size of a cell is too slow (ie, a massive number of cells displayed). If number_of_rows is -1, then the fixed height is unset, and the height is determined by the properties again.

Parameters:

  • number_of_rows — Number of rows of text each cell renderer is allocated, or -1

Virtual methods

do_edited

def do_edited(self, path: str, new_text: str) -> None

Properties

align_set

align_set: bool  # read/write

alignment

alignment: Pango.Alignment | int  # read/write

Specifies how to align the lines of text with respect to each other.

Note that this property describes how to align the lines of text in case there are several of them. The "xalign" property of GtkCellRenderer, on the other hand, sets the horizontal alignment of the whole text.

attributes

attributes: Pango.AttrList  # read/write

background

background: str  # read/write

background_rgba

background_rgba: Gdk.RGBA  # read/write

Background color as a GdkRGBA

background_set

background_set: bool  # read/write

editable

editable: bool  # read/write

editable_set

editable_set: bool  # read/write

ellipsize

ellipsize: Pango.EllipsizeMode | int  # read/write

Specifies the preferred place to ellipsize the string, if the cell renderer does not have enough room to display the entire string. Setting it to Pango.EllipsizeMode.NONE turns off ellipsizing. See the wrap-width property for another way of making the text fit into a given width.

ellipsize_set

ellipsize_set: bool  # read/write

family

family: str  # read/write

family_set

family_set: bool  # read/write

font

font: str  # read/write

font_desc

font_desc: Pango.FontDescription  # read/write

foreground

foreground: str  # read/write

foreground_rgba

foreground_rgba: Gdk.RGBA  # read/write

Foreground color as a GdkRGBA

foreground_set

foreground_set: bool  # read/write

language

language: str  # read/write

language_set

language_set: bool  # read/write

markup

markup: str  # read/write

max_width_chars

max_width_chars: int  # read/write

The desired maximum width of the cell, in characters. If this property is set to -1, the width will be calculated automatically.

For cell renderers that ellipsize or wrap text; this property controls the maximum reported width of the cell. The cell should not receive any greater allocation unless it is set to expand in its GtkCellLayout and all of the cell's siblings have received their natural width.

placeholder_text

placeholder_text: str  # read/write

The text that will be displayed in the GtkCellRenderer if GtkCellRendererText:editable is True and the cell is empty.

rise

rise: int  # read/write

rise_set

rise_set: bool  # read/write

scale

scale: float  # read/write

scale_set

scale_set: bool  # read/write

single_paragraph_mode

single_paragraph_mode: bool  # read/write

size

size: int  # read/write

size_points

size_points: float  # read/write

size_set

size_set: bool  # read/write

stretch

stretch: Pango.Stretch | int  # read/write

stretch_set

stretch_set: bool  # read/write

strikethrough

strikethrough: bool  # read/write

strikethrough_set

strikethrough_set: bool  # read/write

style

style: Pango.Style | int  # read/write

style_set

style_set: bool  # read/write

text

text: str  # read/write

underline

underline: Pango.Underline | int  # read/write

underline_set

underline_set: bool  # read/write

variant

variant: Pango.Variant | int  # read/write

variant_set

variant_set: bool  # read/write

weight

weight: int  # read/write

weight_set

weight_set: bool  # read/write

width_chars

width_chars: int  # read/write

The desired width of the cell, in characters. If this property is set to -1, the width will be calculated automatically, otherwise the cell will request either 3 characters or the property value, whichever is greater.

wrap_mode

wrap_mode: Pango.WrapMode | int  # read/write

Specifies how to break the string into multiple lines, if the cell renderer does not have enough room to display the entire string. This property has no effect unless the wrap-width property is set.

wrap_width

wrap_width: int  # read/write

Specifies the minimum width at which the text is wrapped. The wrap-mode property can be used to influence at what character positions the line breaks can be placed. Setting wrap-width to -1 turns wrapping off.

Signals

edited

def on_edited(self, path: str, new_text: str) -> None: ...

This signal is emitted after renderer has been edited.

It is the responsibility of the application to update the model and store new_text at the position indicated by path.