Clutter.Units

Fields

Name

Type

Access

Description

pixels

float

r

pixels_set

int

r

serial

int

r

unit_type

Clutter.UnitType

r

value

float

r

Methods

class

from_cm (cm)

class

from_em (em)

class

from_em_for_font (font_name, em)

class

from_mm (mm)

class

from_pixels (px)

class

from_pt (pt)

class

from_string (str)

copy ()

free ()

get_unit_type ()

get_unit_value ()

to_pixels ()

to_string ()

Details

class Clutter.Units

An opaque structure, to be used to store sizing and positioning values along with their unit.

New in version 1.0.

classmethod from_cm(cm)
Parameters:

cm (float) – centimeters

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in centimeters inside units

New in version 1.2.

classmethod from_em(em)
Parameters:

em (float) – em

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in em inside units, using the default font name as returned by Clutter.Backend.get_font_name()

New in version 1.0.

classmethod from_em_for_font(font_name, em)
Parameters:
  • font_name (str or None) – the font name and size

  • em (float) – em

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in em inside units using font_name

New in version 1.0.

classmethod from_mm(mm)
Parameters:

mm (float) – millimeters

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in millimiters inside units

New in version 1.0.

classmethod from_pixels(px)
Parameters:

px (int) – pixels

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in pixels inside units

New in version 1.0.

classmethod from_pt(pt)
Parameters:

pt (float) – typographic points

Returns:

a Clutter.Units

Return type:

units: Clutter.Units

Stores a value in typographic points inside units

New in version 1.0.

classmethod from_string(str)
Parameters:

str (str) – the string to convert

Returns:

True if the string was successfully parsed, and False otherwise

units:

a Clutter.Units

Return type:

(bool, units: Clutter.Units)

Parses a value and updates units with it

A Clutter.Units expressed in string should match:

units: wsp* unit-value wsp* unit-name? wsp*
unit-value: number
unit-name: 'px' | 'pt' | 'mm' | 'em' | 'cm'
number: digit+
        | digit* sep digit+
sep: '.' | ','
digit: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
wsp: (#0x20 | #0x9 | #0xA | #0xB | #0xC | #0xD)+

For instance, these are valid strings:

10 px
5.1 em
24 pt
12.6 mm
.3 cm

While these are not:

42 cats
omg!1!ponies

If no unit is specified, pixels are assumed.

New in version 1.0.

copy()
Returns:

the newly created copy of a Clutter.Units structure. Use Clutter.Units.free() to free the allocated resources

Return type:

Clutter.Units

Copies self

New in version 1.0.

free()

Frees the resources allocated by self

You should only call this function on a Clutter.Units created using Clutter.Units.copy()

New in version 1.0.

get_unit_type()
Returns:

a unit type

Return type:

Clutter.UnitType

Retrieves the unit type of the value stored inside self

New in version 1.0.

get_unit_value()
Returns:

the value stored inside a Clutter.Units

Return type:

float

Retrieves the value stored inside self

New in version 1.0.

to_pixels()
Returns:

the value in pixels

Return type:

float

Converts a value in Clutter.Units to pixels

New in version 1.0.

to_string()
Returns:

a newly allocated string containing the encoded Clutter.Units value. Use GLib.free() to free the string

Return type:

str

Converts self into a string

See Clutter.Units.from_string() for the units syntax and for examples of output

Fractional values are truncated to the second decimal position for em, mm and cm, and to the first decimal position for typographic points. Pixels are integers.

New in version 1.0.