Gtk.CellRenderer
Gtk.CellRenderer — An object for rendering a single cell
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.CellRenderer
├── Gtk.CellRendererText
├── Gtk.CellRendererPixbuf
├── Gtk.CellRendererProgress
├── Gtk.CellRendererSpinner
╰── Gtk.CellRendererToggle
See also:
Gtk.CellRendererText, Gtk.CellRendererPixbuf, Gtk.CellRendererToggle
Functions:
- get_aligned_area
(self, widget:Gtk.Widget, flags:Gtk.CellRendererState, cell_area:Gdk.Rectangle) -> aligned_area:Gdk.Rectangle - get_size
(self, widget:Gtk.Widget, cell_area:Gdk.Rectangle=None) -> x_offset:int, y_offset:int, width:int, height:int - render
(self, cr:cairo.Context, widget:Gtk.Widget, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState) - activate
(self, event:Gdk.Event, widget:Gtk.Widget, path:str, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState) -> bool - start_editing
(self, event:Gdk.Event, widget:Gtk.Widget, path:str, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState) -> Gtk.CellEditable - stop_editing
(self, canceled:bool) - get_fixed_size
(self) -> width:int, height:int - set_fixed_size
(self, width:int, height:int) - get_visible
(self) -> bool - set_visible
(self, visible:bool) - get_sensitive
(self) -> bool - set_sensitive
(self, sensitive:bool) - get_alignment
(self) -> xalign:float, yalign:float - set_alignment
(self, xalign:float, yalign:float) - get_padding
(self) -> xpad:int, ypad:int - set_padding
(self, xpad:int, ypad:int) - get_state
(self, widget:Gtk.Widget, cell_state:Gtk.CellRendererState) -> Gtk.StateFlags - is_activatable
(self) -> bool - get_preferred_height
(self, widget:Gtk.Widget) -> minimum_size:int, natural_size:int - get_preferred_height_for_width
(self, widget:Gtk.Widget, width:int) -> minimum_height:int, natural_height:int - get_preferred_size
(self, widget:Gtk.Widget) -> minimum_size:Gtk.Requisition, natural_size:Gtk.Requisition - get_preferred_width
(self, widget:Gtk.Widget) -> minimum_size:int, natural_size:int - get_preferred_width_for_height
(self, widget:Gtk.Widget, height:int) -> minimum_width:int, natural_width:int - get_request_mode
(self) -> Gtk.SizeRequestMode
Signals:
- “editing-canceled”
(renderer, user_data)
Description:
The Gtk.CellRenderer is a base class of a set of objects used for rendering a cell to a #cairo_t. These objects are used primarily by the Gtk.TreeView widget, though they aren’t tied to them in any specific way. It is worth noting that Gtk.CellRenderer is not a Gtk.Widget and cannot be treated as such.
The primary use of a Gtk.CellRenderer is for drawing a certain graphical elements on a #cairo_t. 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 using #GObjects property system. Then, the cell is measured using Gtk.CellRenderer::get_size(). Finally, the cell is rendered in the correct location using Gtk.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 a GtkStyle change. The Gtk.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 like Gtk.CellRendererText, which allows the user to edit the text using a 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.
Function Details:
get_aligned_area()
get_aligned_area (self, widget:Gtk.Widget, flags:Gtk.CellRendererState, cell_area:Gdk.Rectangle) -> aligned_area:Gdk.Rectangle
Gets the aligned area used by cell inside cell_area. Used for findingthe appropriate edit and focus rectangle.
- Since: 3.0
get_size()
get_size (self, widget:Gtk.Widget, cell_area:Gdk.Rectangle=None) -> x_offset:int, y_offset:int, width:int, height:int
Gtk.CellRenderer:get_size has been deprecated since version 3.0 and should not be used in newly-written code.
Use Gtk.CellRenderer:get_preferred_size() instead.
Obtains the width and height needed to render the cell. Used by view widgets to determine the appropriate size for the cell_area passed toGtk.CellRenderer:render(). If cell_area is not None, fills in thex 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.
render()
render (self, cr:cairo.Context, widget:Gtk.Widget, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState)
Invokes the virtual render function of the Gtk.CellRenderer. The threepassed-in rectangles are areas in cr. Most renderers will draw withincell_area; the xalign, yalign, xpad, and ypad fields of the Gtk.CellRenderershould be honored with respect to cell_area. background_area includes theblank space around the cell, and also the area containing the tree expander;so the background_area rectangles for all cells tile to cover the entirewindow.
activate()
activate (self, event:Gdk.Event, widget:Gtk.Widget, path:str, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState) -> bool
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.
- Returns:
Trueif the event was consumed/handled
start_editing()
start_editing (self, event:Gdk.Event, widget:Gtk.Widget, path:str, background_area:Gdk.Rectangle, cell_area:Gdk.Rectangle, flags:Gtk.CellRendererState) -> Gtk.CellEditable
Passes an activate event to the cell renderer for possible processing.
- Returns:
A new
Gtk.CellEditable, orNone.
stop_editing()
stop_editing (self, canceled:bool)
Informs the cell renderer that the editing is stopped.If canceled is True, the cell renderer will emit the “editing-canceled” signal.
This function should be called by cell renderer implementations in response to the “editing-done” signal of Gtk.CellEditable.
- Since: 2.6
get_fixed_size()
get_fixed_size (self) -> width:int, height:int
Fills in width and height with the appropriate size of cell.
set_fixed_size()
set_fixed_size (self, width:int, height:int)
Sets the renderer size to be explicit, independent of the properties set.
get_visible()
get_visible (self) -> bool
Returns the cell renderer’s visibility.
Returns:
Trueif the cell renderer is visibleSince: 2.18
set_visible()
set_visible (self, visible:bool)
Sets the cell renderer’s visibility.
- Since: 2.18
get_sensitive()
get_sensitive (self) -> bool
Returns the cell renderer’s sensitivity.
Returns:
Trueif the cell renderer is sensitiveSince: 2.18
set_sensitive()
set_sensitive (self, sensitive:bool)
Sets the cell renderer’s sensitivity.
- Since: 2.18
get_alignment()
get_alignment (self) -> xalign:float, yalign:float
Fills in xalign and yalign with the appropriate values of cell.
- Since: 2.18
set_alignment()
set_alignment (self, xalign:float, yalign:float)
Sets the renderer’s alignment within its available space.
- Since: 2.18
get_padding()
get_padding (self) -> xpad:int, ypad:int
Fills in xpad and ypad with the appropriate values of cell.
- Since: 2.18
set_padding()
set_padding (self, xpad:int, ypad:int)
Sets the renderer’s padding.
- Since: 2.18
get_state()
get_state (self, widget:Gtk.Widget, cell_state:Gtk.CellRendererState) -> Gtk.StateFlags
Translates the cell renderer state to Gtk.StateFlags,based on the cell renderer and widget sensitivity, andthe given Gtk.CellRendererState.
Returns: the widget state flags applying to
cellSince: 3.0
is_activatable()
is_activatable (self) -> bool
Checks whether the cell renderer can do something when activated.
Returns:
Trueif the cell renderer can do anything when activatedSince: 3.0
get_preferred_height()
get_preferred_height (self, widget:Gtk.Widget) -> minimum_size:int, natural_size:int
Retreives a renderer’s natural size when rendered to widget.
- Since: 3.0
get_preferred_height_for_width()
get_preferred_height_for_width (self, widget:Gtk.Widget, width:int) -> minimum_height:int, natural_height:int
Retreives a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
- Since: 3.0
get_preferred_size()
get_preferred_size (self, widget:Gtk.Widget) -> minimum_size:Gtk.Requisition, natural_size:Gtk.Requisition
Retrieves the minimum and natural size of a cell takinginto account the widget’s preference for height-for-width management.
- Since: 3.0
get_preferred_width()
get_preferred_width (self, widget:Gtk.Widget) -> minimum_size:int, natural_size:int
Retreives a renderer’s natural size when rendered to widget.
- Since: 3.0
get_preferred_width_for_height()
get_preferred_width_for_height (self, widget:Gtk.Widget, height:int) -> minimum_width:int, natural_width:int
Retreives a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
- Since: 3.0
get_request_mode()
get_request_mode (self) -> Gtk.SizeRequestMode
Gets whether the cell renderer prefers a height-for-width layoutor a width-for-height layout.
Returns: The
Gtk.SizeRequestModepreferred by this renderer.Since: 3.0