gtk.CellRenderer — a base class for objects that render on a gtk.gdk.Drawable
class gtk.CellRenderer(gtk.Object): |
|
def callback( | |
def callback( |
The gtk.CellRenderer
is a base class for a set of objects used for rendering a cell to a gtk.gdk.Drawable
. The
gtk.CellRenderer
provides the common attributes and methods for its subclasses (gtk.CellRendererPixbuf
,
gtk.CellRendererText
and gtk.CellRendererToggle
).
The primary use of a gtk.CellRenderer
is for drawing a certain graphical elements on a gtk.gdk.Drawable
. 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 the GObjects
property system. Then, the cell is measured using the get_size
()
method. Finally, the cell is rendered in the correct location using the
render
()
method.
def get_size(widget
, cell_area
)
| the widget the renderer is rendering to |
| The area a cell will be allocated, or None |
Returns : | a tuple containing the xoffset, yoffset, width and height |
The get_size
() method obtains the width
and height needed to render the cell. These values are returned as part of a
tuple containing the x_offset, y_offset, width and height.
get_size
() is used by view widgets to determine the
appropriate size for the cell_area
to be passed to the gtk.CellRenderer.render()
method. If cell_area
is not None
,
the x and y offsets of the cell relative to this location are returned.
Please note that the values set in the returned width and height, as well as
those in x_offset and y_offset are inclusive of the xpad and ypad
properties.
def render(window
, widget
, background_area
, cell_area
, expose_area
, flags
)
| a gtk.gdk.Drawable to draw to |
| the widget owning window |
| entire cell area (including tree expanders and maybe padding on the sides) |
| area normally rendered by a cell renderer |
| area that actually needs updating |
| flags that affect rendering |
The render
() method invokes the virtual
render function of the gtk.CellRenderer
.
The three passed-in rectangles are areas of window
.
Most renderers will draw within cell_area
; the
xalign, yalign, xpad, and ypad properties of the gtk.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
.
expose_area
is a clip rectangle.
The flags
value is one of:
gtk.CELL_RENDERER_SELECTED
,
gtk.CELL_RENDERER_PRELIT
,
gtk.CELL_RENDERER_INSENSITIVE
or
gtk.CELL_RENDERER_SORTED
def activate(event
, widget
, path
, background_area
, cell_area
, flags
)
| a gtk.gdk.Event |
| widget that received the event |
| widget-dependent string representation of the event location; e.g. for gtk.TreeView , a string representation of gtk.TreePath |
| background area as passed to render () |
| cell area as passed to render () |
| render flags |
Returns : | True if the event was consumed/handled |
The activate
() method 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.
The flags
value is one of:
gtk.CELL_RENDERER_SELECTED
,
gtk.CELL_RENDERER_PRELIT
,
gtk.CELL_RENDERER_INSENSITIVE
or
gtk.CELL_RENDERER_SORTED
def start_editing(event
, widget
, path
, background_area
, cell_area
, flags
)
| a gtk.gdk.Event |
| the widget that received the event |
| a widget-dependent string representation of the event location; e.g. for gtk.TreeView , a string representation of gtk.TreePath |
| background area as passed to render (). |
| cell area as passed to render () |
| render flags |
Returns : | A new gtk.CellEditable , or None |
The start_editing
() method initiates
the editing of a cell.
def editing_canceled()
This method is available in PyGTK 2.4 and above.
This method is deprecated in PyGTK 2.6 and above and should not be used in newly-written code. Use the
stop_editing
()
method instead.
The editing_canceled
() method causes
the cell renderer to emit the "editing-canceled" signal. This method is for
use only by implementations of cell renderers that need to notify the client
program that an editing process was canceled and the changes were not
committed.
def stop_editing(canceled
)
| if True the editing has been canceled |
This method is available in PyGTK 2.6 and above.
The stop_editing
() method informs the
cell renderer that the editing is stopped. If
canceled
is True
, the cell
renderer will emit the "editing-canceled" signal. This method should be
called by cell renderer implementations in response to the "editing-done"
signal of gtk.CellEditable
.
def set_fixed_size(width
, height
)
| the width of the cell renderer, or -1 |
| the height of the cell renderer, or -1 |
The set_fixed_size
() method sets the
renderer size to the specified width
and
height
, independent of the properties set.
def get_fixed_size()
Returns : | a tuple containing the width and height of the cell |
The get_fixed_size
() method retrieves a
tuple containing the fixed width
and
height
of the cell.
def set_visible(visible
)
| the cell renderer's visibility. |
This method is available in PyGTK 2.22 and above.
The set_visible
() method sets the cell
renderer's visibility.
def get_visible()
Returns : | the cell renderer's visibility. |
This method is available in PyGTK 2.22 and above.
The get_visible
() method gets the cell
renderer's visibility.
def set_sensitive(sensitive
)
| the cell renderer's sensitivity. |
This method is available in PyGTK 2.22 and above.
The set_sensitive
() method sets the cell
renderer's sensitivity.
def get_sensitive()
Returns : | the cell renderer's sensitivity. |
This method is available in PyGTK 2.22 and above.
The get_sensitive
() method gets the cell
renderer's sensitivity.
def set_alignment(xalign
, yalign
)
| the x alignment of the cell renderer. |
| the y alignment of the cell renderer. |
This method is available in PyGTK 2.22 and above.
The set_alignment
() method sets the renderer's
alignment within its available space.
def get_alignment()
Returns : | a 2-tuple containing the cell renderer's alignment within its available space. |
This method is available in PyGTK 2.22 and above.
The get_alignment
() gets the the renderer's
alignment within its available space.
def callback(cellrenderer
, user_param1
, ...
)
| the cellrenderer that received the signal |
| the first user parameter (if any) specified with the connect () |
| additional user parameters (if any) |
This signal is available in GTK+ 2.4 and above.
The "editing-canceled" signal is 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. Also
see the editing_canceled
()
method.
def callback(cellrenderer
, editable
, path
, user_param1
, ...
)
| the cellrenderer that received the signal |
| the gtk.CellEditable |
| he path identifying the edited cell |
| the first user parameter (if any) specified with the connect () |
| additional user parameters (if any) |
This signal is available in GTK+ 2.6 and above.
The "editing-started" signal is 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 a gtk.ComboBox
.
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:
def text_editing_started(cell, editable, path, data): if isinstance(editable, gtk.Entry): # ... create a GtkEntryCompletion completion = gtk.EntryCompletion() editable.set_completion(completion) ... ...