:right-sidebar: True CellRendererText =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 List views use widgets to display their contents. You should use :obj:`~gi.repository.Gtk.Inscription` or :obj:`~gi.repository.Gtk.Label` instead .. class:: CellRendererText(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.CellRenderer`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.CellRendererAccel`, :class:`~gi.repository.Gtk.CellRendererCombo`, :class:`~gi.repository.Gtk.CellRendererSpin` 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 :const:`~gi.repository.Gtk.CellRendererMode.EDITABLE`, the ``GtkCellRendererText`` allows to edit its text using an entry. Constructors ------------ .. rst-class:: interim-class .. class:: CellRendererText :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.CellRenderer Creates a new ``GtkCellRendererText``. Adjust how text is drawn using object properties. Object properties can be set globally (with :func:`~gi.repository.GObject.GObject.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``. .. deprecated:: 4.10 Please do not use it in newly written code Methods ------- .. rst-class:: interim-class .. class:: CellRendererText :no-index: .. method:: set_fixed_height_from_font(number_of_rows: int) -> None 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. .. deprecated:: 4.10 Please do not use it in newly written code :param number_of_rows: Number of rows of text each cell renderer is allocated, or -1 Properties ---------- .. rst-class:: interim-class .. class:: CellRendererText :no-index: .. attribute:: props.align_set :type: bool .. attribute:: props.alignment :type: ~gi.repository.Pango.Alignment 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. .. attribute:: props.attributes :type: ~gi.repository.Pango.AttrList .. attribute:: props.background :type: str .. attribute:: props.background_rgba :type: ~gi.repository.Gdk.RGBA Background color as a ``GdkRGBA`` .. attribute:: props.background_set :type: bool .. attribute:: props.editable :type: bool .. attribute:: props.editable_set :type: bool .. attribute:: props.ellipsize :type: ~gi.repository.Pango.EllipsizeMode 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_ELLIPSIZE_NONE`` turns off ellipsizing. See the wrap-width property for another way of making the text fit into a given width. .. attribute:: props.ellipsize_set :type: bool .. attribute:: props.family :type: str .. attribute:: props.family_set :type: bool .. attribute:: props.font :type: str .. attribute:: props.font_desc :type: ~gi.repository.Pango.FontDescription .. attribute:: props.foreground :type: str .. attribute:: props.foreground_rgba :type: ~gi.repository.Gdk.RGBA Foreground color as a ``GdkRGBA`` .. attribute:: props.foreground_set :type: bool .. attribute:: props.language :type: str .. attribute:: props.language_set :type: bool .. attribute:: props.markup :type: str .. attribute:: props.max_width_chars :type: int 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. .. attribute:: props.placeholder_text :type: str The text that will be displayed in the ``GtkCellRenderer`` if ``GtkCellRendererText:editable`` is :const:`True` and the cell is empty. .. attribute:: props.rise :type: int .. attribute:: props.rise_set :type: bool .. attribute:: props.scale :type: float .. attribute:: props.scale_set :type: bool .. attribute:: props.single_paragraph_mode :type: bool .. attribute:: props.size :type: int .. attribute:: props.size_points :type: float .. attribute:: props.size_set :type: bool .. attribute:: props.stretch :type: ~gi.repository.Pango.Stretch .. attribute:: props.stretch_set :type: bool .. attribute:: props.strikethrough :type: bool .. attribute:: props.strikethrough_set :type: bool .. attribute:: props.style :type: ~gi.repository.Pango.Style .. attribute:: props.style_set :type: bool .. attribute:: props.text :type: str .. attribute:: props.underline :type: ~gi.repository.Pango.Underline .. attribute:: props.underline_set :type: bool .. attribute:: props.variant :type: ~gi.repository.Pango.Variant .. attribute:: props.variant_set :type: bool .. attribute:: props.weight :type: int .. attribute:: props.weight_set :type: bool .. attribute:: props.width_chars :type: int 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. .. attribute:: props.wrap_mode :type: ~gi.repository.Pango.WrapMode 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. .. attribute:: props.wrap_width :type: int 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 ------- .. rst-class:: interim-class .. class:: CellRendererText.signals :no-index: .. method:: edited(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``. :param path: the path identifying the edited cell :param new_text: the new text Virtual Methods --------------- .. rst-class:: interim-class .. class:: CellRendererText :no-index: .. method:: do_edited(path: str, new_text: str) -> None :param path: :param new_text: Fields ------ .. rst-class:: interim-class .. class:: CellRendererText :no-index: .. attribute:: parent