Gtk.CellRenderer¶
- Subclasses:
Gtk.CellRendererPixbuf
,Gtk.CellRendererProgress
,Gtk.CellRendererSpinner
,Gtk.CellRendererText
,Gtk.CellRendererToggle
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
w |
Cell background color as a string |
||
d/r/w |
Cell background color as a |
||
r/w |
Cell background color as a |
||
r/w/en |
Whether the cell background color is set |
||
r |
Whether the cell renderer is currently in editing mode |
||
r/w/en |
The fixed height |
||
r/w/en |
Row is an expander row, and is expanded |
||
r/w/en |
Row has children |
||
r/w/en |
Editable mode of the CellRenderer |
||
r/w/en |
|
||
r/w/en |
|
||
r/w/en |
The fixed width |
||
r/w/en |
The x-align |
||
r/w/en |
The xpad |
||
r/w/en |
The y-align |
||
r/w/en |
The ypad |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal gets emitted when the user cancels the process of editing a cell. |
|
This signal gets emitted when a cell starts to be edited. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.CellRenderer(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
The
Gtk.CellRenderer
is a base class of a set of objects used for rendering a cell to acairo.Context
. These objects are used primarily by theGtk.TreeView
widget, though they aren’t tied to them in any specific way. It is worth noting thatGtk.CellRenderer
is not aGtk.Widget
and cannot be treated as such.The primary use of a
Gtk.CellRenderer
is for drawing a certain graphical elements on acairo.Context
. Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn’t expected that a CellRenderer keep any permanent state around. Instead, any state is set just prior to use usingGObject.Objects
property system. Then, the cell is measured usingGtk.CellRenderer.get_size
(). Finally, the cell is rendered in the correct location usingGtk.CellRenderer.render
().There are a number of rules that must be followed when writing a new
Gtk.CellRenderer
. First and foremost, it’s important that a certain set of properties will always yield a cell renderer of the same size, barring aGtk.Style
change. TheGtk.CellRenderer
also has a number of generic properties that are expected to be honored by all children.Beyond merely rendering a cell, cell renderers can optionally provide active user interface elements. A cell renderer can be “activatable” like
Gtk.CellRendererToggle
, which toggles when it gets activated by a mouse click, or it can be “editable” likeGtk.CellRendererText
, which allows the user to edit the text using a widget implementing theGtk.CellEditable
interface, e.g.Gtk.Entry
. To make a cell renderer activatable or editable, you have to implement the Gtk.CellRendererClass.activate or Gtk.CellRendererClass.start_editing virtual functions, respectively.Many properties of
Gtk.CellRenderer
and its subclasses have a corresponding “set” property, e.g. “cell-background-set” corresponds to “cell-background”. These “set” properties reflect whether a property has been set or not. You should not set them independently.- classmethod set_accessible_type(type)¶
- Parameters:
type (
GObject.GType
) – The object type that implements the accessible for widget_class. The type must be a subtype ofGtk.RendererCellAccessible
Sets the type to be used for creating accessibles for cells rendered by cell renderers of self. Note that multiple accessibles will be created.
This function should only be called from class init functions of cell renderers.
- activate(event, widget, path, background_area, cell_area, flags)[source]¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtk.TreeView
, a string representation ofGtk.TreePath
background_area (
Gdk.Rectangle
) – background area as passed toGtk.CellRenderer.render
()cell_area (
Gdk.Rectangle
) – cell area as passed toGtk.CellRenderer.render
()flags (
Gtk.CellRendererState
) – render flags
- Returns:
True
if the event was consumed/handled- Return type:
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example,
Gtk.CellRendererToggle
toggles when it gets a mouse click.
- get_aligned_area(widget, flags, cell_area)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering toflags (
Gtk.CellRendererState
) – render flagscell_area (
Gdk.Rectangle
) – cell area which would be passed toGtk.CellRenderer.render
()
- Returns:
the return location for the space inside cell_area that would acually be used to render.
- Return type:
aligned_area:
Gdk.Rectangle
Gets the aligned area used by self inside cell_area. Used for finding the appropriate edit and focus rectangle.
New in version 3.0.
- get_alignment()[source]¶
- Returns:
- Return type:
Fills in xalign and yalign with the appropriate values of self.
New in version 2.18.
- get_fixed_size()[source]¶
- Returns:
- Return type:
Fills in width and height with the appropriate size of self.
- get_padding()[source]¶
- Returns:
- Return type:
Fills in xpad and ypad with the appropriate values of self.
New in version 2.18.
- get_preferred_height(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering to- Returns:
- Return type:
Retreives a renderer’s natural size when rendered to widget.
New in version 3.0.
- get_preferred_height_for_width(widget, width)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering towidth (
int
) – the size which is available for allocation
- Returns:
- Return type:
Retreives a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
New in version 3.0.
- get_preferred_size(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering to- Returns:
- Return type:
(minimum_size:
Gtk.Requisition
, natural_size:Gtk.Requisition
)
Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.
New in version 3.0.
- get_preferred_width(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering to- Returns:
- Return type:
Retreives a renderer’s natural size when rendered to widget.
New in version 3.0.
- get_preferred_width_for_height(widget, height)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering toheight (
int
) – the size which is available for allocation
- Returns:
- Return type:
Retreives a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
New in version 3.0.
- get_request_mode()[source]¶
- Returns:
The
Gtk.SizeRequestMode
preferred by this renderer.- Return type:
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
New in version 3.0.
- get_size(widget, cell_area)[source]¶
- Parameters:
widget (
Gtk.Widget
) – the widget the renderer is rendering tocell_area (
Gdk.Rectangle
orNone
) – The area a cell will be allocated, orNone
- Returns:
- Return type:
Obtains the width and height needed to render the cell. Used by view widgets to determine the appropriate size for the cell_area passed to
Gtk.CellRenderer.render
(). If cell_area is notNone
, fills in the x and y offsets (if set) of the cell relative to this location.Please note that the values set in width and height, as well as those in x_offset and y_offset are inclusive of the xpad and ypad properties.
Deprecated since version 3.0: Use
Gtk.CellRenderer.get_preferred_size
() instead.
- get_state(widget, cell_state)[source]¶
- Parameters:
widget (
Gtk.Widget
orNone
) – aGtk.Widget
, orNone
cell_state (
Gtk.CellRendererState
) – cell renderer state
- Returns:
the widget state flags applying to self
- Return type:
Translates the cell renderer state to
Gtk.StateFlags
, based on the cell renderer and widget sensitivity, and the givenGtk.CellRendererState
.New in version 3.0.
- is_activatable()[source]¶
-
Checks whether the cell renderer can do something when activated.
New in version 3.0.
- render(cr, widget, background_area, cell_area, flags)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo context to draw towidget (
Gtk.Widget
) – the widget owning windowbackground_area (
Gdk.Rectangle
) – entire cell area (including tree expanders and maybe padding on the sides)cell_area (
Gdk.Rectangle
) – area normally rendered by a cell rendererflags (
Gtk.CellRendererState
) – flags that affect rendering
Invokes the virtual render function of the
Gtk.CellRenderer
. The three passed-in rectangles are areas in cr. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of theGtk.CellRenderer
should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window.
- set_alignment(xalign, yalign)[source]¶
- Parameters:
Sets the renderer’s alignment within its available space.
New in version 2.18.
- set_fixed_size(width, height)[source]¶
- Parameters:
Sets the renderer size to be explicit, independent of the properties set.
- set_sensitive(sensitive)[source]¶
- Parameters:
sensitive (
bool
) – the sensitivity of the cell
Sets the cell renderer’s sensitivity.
New in version 2.18.
- set_visible(visible)[source]¶
- Parameters:
visible (
bool
) – the visibility of the cell
Sets the cell renderer’s visibility.
New in version 2.18.
- start_editing(event, widget, path, background_area, cell_area, flags)[source]¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtk.TreeView
, a string representation ofGtk.TreePath
background_area (
Gdk.Rectangle
) – background area as passed toGtk.CellRenderer.render
()cell_area (
Gdk.Rectangle
) – cell area as passed toGtk.CellRenderer.render
()flags (
Gtk.CellRendererState
) – render flags
- Returns:
A new
Gtk.CellEditable
for editing this self, orNone
if editing is not possible- Return type:
Starts editing the contents of this self, through a new
Gtk.CellEditable
widget created by the Gtk.CellRendererClass.start_editing virtual function.
- stop_editing(canceled)[source]¶
-
Informs the cell renderer that the editing is stopped. If canceled is
True
, the cell renderer will emit theGtk.CellRenderer
::editing-canceled
signal.This function should be called by cell renderer implementations in response to the
Gtk.CellEditable
::editing-done
signal ofGtk.CellEditable
.New in version 2.6.
- do_activate(event, widget, path, background_area, cell_area, flags) virtual¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtk.TreeView
, a string representation ofGtk.TreePath
background_area (
Gdk.Rectangle
) – background area as passed toGtk.CellRenderer.render
()cell_area (
Gdk.Rectangle
) – cell area as passed toGtk.CellRenderer.render
()flags (
Gtk.CellRendererState
) – render flags
- Returns:
True
if the event was consumed/handled- Return type:
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example,
Gtk.CellRendererToggle
toggles when it gets a mouse click.
- do_editing_canceled() virtual¶
Signal gets emitted when the user cancels the process of editing a cell.
- do_editing_started(editable, path) virtual¶
- Parameters:
editable (
Gtk.CellEditable
) –path (
str
) –
Signal gets emitted when a cell starts to be edited.
- do_get_aligned_area(widget, flags, cell_area) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering toflags (
Gtk.CellRendererState
) – render flagscell_area (
Gdk.Rectangle
) – cell area which would be passed toGtk.CellRenderer.render
()
- Returns:
the return location for the space inside cell_area that would acually be used to render.
- Return type:
aligned_area:
Gdk.Rectangle
Gets the aligned area used by cell inside cell_area. Used for finding the appropriate edit and focus rectangle.
New in version 3.0.
- do_get_preferred_height(widget) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering to- Returns:
- Return type:
Retreives a renderer’s natural size when rendered to widget.
New in version 3.0.
- do_get_preferred_height_for_width(widget, width) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering towidth (
int
) – the size which is available for allocation
- Returns:
- Return type:
Retreives a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
New in version 3.0.
- do_get_preferred_width(widget) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering to- Returns:
- Return type:
Retreives a renderer’s natural size when rendered to widget.
New in version 3.0.
- do_get_preferred_width_for_height(widget, height) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtk.Widget
this cell will be rendering toheight (
int
) – the size which is available for allocation
- Returns:
- Return type:
Retreives a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
New in version 3.0.
- do_get_request_mode() virtual¶
- Returns:
The
Gtk.SizeRequestMode
preferred by this renderer.- Return type:
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
New in version 3.0.
- do_get_size(widget, cell_area) virtual¶
- Parameters:
widget (
Gtk.Widget
) – the widget the renderer is rendering tocell_area (
Gdk.Rectangle
orNone
) – The area a cell will be allocated, orNone
- Returns:
- Return type:
Obtains the width and height needed to render the cell. Used by view widgets to determine the appropriate size for the cell_area passed to
Gtk.CellRenderer.render
(). If cell_area is notNone
, fills in the x and y offsets (if set) of the cell relative to this location.Please note that the values set in width and height, as well as those in x_offset and y_offset are inclusive of the xpad and ypad properties.
Deprecated since version 3.0: Use
Gtk.CellRenderer.get_preferred_size
() instead.
- do_render(cr, widget, background_area, cell_area, flags) virtual¶
- Parameters:
cr (
cairo.Context
) – a cairo context to draw towidget (
Gtk.Widget
) – the widget owning windowbackground_area (
Gdk.Rectangle
) – entire cell area (including tree expanders and maybe padding on the sides)cell_area (
Gdk.Rectangle
) – area normally rendered by a cell rendererflags (
Gtk.CellRendererState
) – flags that affect rendering
Invokes the virtual render function of the
Gtk.CellRenderer
. The three passed-in rectangles are areas in cr. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of theGtk.CellRenderer
should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window.
- do_start_editing(event, widget, path, background_area, cell_area, flags) virtual¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtk.TreeView
, a string representation ofGtk.TreePath
background_area (
Gdk.Rectangle
) – background area as passed toGtk.CellRenderer.render
()cell_area (
Gdk.Rectangle
) – cell area as passed toGtk.CellRenderer.render
()flags (
Gtk.CellRendererState
) – render flags
- Returns:
A new
Gtk.CellEditable
for editing this cell, orNone
if editing is not possible- Return type:
Starts editing the contents of this cell, through a new
Gtk.CellEditable
widget created by the Gtk.CellRendererClass.start_editing virtual function.
Signal Details¶
- Gtk.CellRenderer.signals.editing_canceled(cell_renderer)¶
- Signal Name:
editing-canceled
- Flags:
- Parameters:
cell_renderer (
Gtk.CellRenderer
) – The object which received the signal
This signal gets emitted when the user cancels the process of editing a cell. For example, an editable cell renderer could be written to cancel editing when the user presses Escape.
See also:
Gtk.CellRenderer.stop_editing
().New in version 2.4.
- Gtk.CellRenderer.signals.editing_started(cell_renderer, editable, path)¶
- Signal Name:
editing-started
- Flags:
- Parameters:
cell_renderer (
Gtk.CellRenderer
) – The object which received the signaleditable (
Gtk.CellEditable
) – theGtk.CellEditable
path (
str
) – the path identifying the edited cell
This signal gets emitted when a cell starts to be edited. The intended use of this signal is to do special setup on editable, e.g. adding a
Gtk.EntryCompletion
or setting up additional columns in aGtk.ComboBox
.See
Gtk.CellEditable.start_editing
() for information on the lifecycle of the editable and a way to do setup that doesn’t depend on the renderer.Note that GTK+ doesn’t guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of editable before doing any specific setup, as in the following example:
static void text_editing_started (GtkCellRenderer *cell, GtkCellEditable *editable, const gchar *path, gpointer data) { if (GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable); // ... create a GtkEntryCompletion gtk_entry_set_completion (entry, completion); } }
New in version 2.6.
Property Details¶
- Gtk.CellRenderer.props.cell_background¶
-
Cell background color as a string
- Gtk.CellRenderer.props.cell_background_gdk¶
- Name:
cell-background-gdk
- Type:
- Default Value:
- Flags:
Cell background as a
Gdk.Color
Deprecated since version 3.4: Use
Gtk.CellRenderer
:cell-background-rgba
instead.
- Gtk.CellRenderer.props.cell_background_set¶
- Name:
cell-background-set
- Type:
- Default Value:
- Flags:
Whether the cell background color is set
- Gtk.CellRenderer.props.editing¶
-
Whether the cell renderer is currently in editing mode
- Gtk.CellRenderer.props.height¶
- Name:
height
- Type:
- Default Value:
-1
- Flags:
The fixed height
- Gtk.CellRenderer.props.is_expanded¶
- Name:
is-expanded
- Type:
- Default Value:
- Flags:
Row is an expander row, and is expanded
- Gtk.CellRenderer.props.is_expander¶
- Name:
is-expander
- Type:
- Default Value:
- Flags:
Row has children
- Gtk.CellRenderer.props.mode¶
- Name:
mode
- Type:
- Default Value:
- Flags:
Editable mode of the CellRenderer
- Gtk.CellRenderer.props.sensitive¶
- Name:
sensitive
- Type:
- Default Value:
- Flags:
xlib.Display
the cell sensitive
- Gtk.CellRenderer.props.visible¶
- Name:
visible
- Type:
- Default Value:
- Flags:
xlib.Display
the cell
- Gtk.CellRenderer.props.width¶
- Name:
width
- Type:
- Default Value:
-1
- Flags:
The fixed width
- Gtk.CellRenderer.props.xalign¶
- Name:
xalign
- Type:
- Default Value:
0.5
- Flags:
The x-align
- Gtk.CellRenderer.props.xpad¶
- Name:
xpad
- Type:
- Default Value:
0
- Flags:
The xpad
- Gtk.CellRenderer.props.yalign¶
- Name:
yalign
- Type:
- Default Value:
0.5
- Flags:
The y-align
- Gtk.CellRenderer.props.ypad¶
- Name:
ypad
- Type:
- Default Value:
0
- Flags:
The ypad