Gtk.Gradient

Fields

None

Methods

class new_linear (x0, y0, x1, y1)
class new_radial (x0, y0, radius0, x1, y1, radius1)
  add_color_stop (offset, color)
  ref ()
  resolve (props)
  resolve_for_context (context)
  to_string ()
  unref ()

Details

class Gtk.Gradient

Gtk.Gradient is a boxed type that represents a gradient. It is the result of parsing a ‘gradient expression [gtkcssprovider-gradients]’. To obtain the gradient represented by a Gtk.Gradient, it has to be resolved with Gtk.Gradient.resolve(), which replaces all symbolic color references by the colors they refer to (in a given context) and constructs a cairo.Pattern value.

It is not normally necessary to deal directly with Gtk.Gradients, since they are mostly used behind the scenes by Gtk.StyleContext and Gtk.CssProvider.

Gtk.Gradient is deprecated. It was used internally by GTK’s CSS engine to represent gradients. As its handling is not conforming to modern web standards, it is not used anymore. If you want to use gradients in your own code, please use Cairo directly.

classmethod new_linear(x0, y0, x1, y1)[source]
Parameters:
  • x0 (float) – X coordinate of the starting point
  • y0 (float) – Y coordinate of the starting point
  • x1 (float) – X coordinate of the end point
  • y1 (float) – Y coordinate of the end point
Returns:

A newly created Gtk.Gradient

Return type:

Gtk.Gradient

Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient a number of stop colors must be added through Gtk.Gradient.add_color_stop().

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

classmethod new_radial(x0, y0, radius0, x1, y1, radius1)[source]
Parameters:
  • x0 (float) – X coordinate of the start circle
  • y0 (float) – Y coordinate of the start circle
  • radius0 (float) – radius of the start circle
  • x1 (float) – X coordinate of the end circle
  • y1 (float) – Y coordinate of the end circle
  • radius1 (float) – radius of the end circle
Returns:

A newly created Gtk.Gradient

Return type:

Gtk.Gradient

Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and (x1, y1, radius1). Before using the gradient a number of stop colors must be added through Gtk.Gradient.add_color_stop().

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

add_color_stop(offset, color)[source]
Parameters:

Adds a stop color to self.

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

ref()[source]
Returns:The same self
Return type:Gtk.Gradient

Increases the reference count of self.

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

resolve(props)[source]
Parameters:props (Gtk.StyleProperties) – Gtk.StyleProperties to use when resolving named colors
Returns:True if the gradient has been resolved
resolved_gradient:
 return location for the resolved pattern
Return type:(bool, resolved_gradient: cairo.Pattern)

If self is resolvable, resolved_gradient will be filled in with the resolved gradient as a cairo.Pattern, and True will be returned. Generally, if self can’t be resolved, it is due to it being defined on top of a named color that doesn’t exist in props.

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

resolve_for_context(context)[source]
Parameters:context (Gtk.StyleContext) –
Return type:cairo.Pattern
to_string()[source]
Returns:A string representation for self
Return type:str

Creates a string representation for self that is suitable for using in GTK CSS files.

Deprecated since version 3.8: Gtk.Gradient is deprecated.

unref()[source]

Decreases the reference count of self, freeing its memory if the reference count reaches 0.

New in version 3.0.

Deprecated since version 3.8: Gtk.Gradient is deprecated.