GimpUi.NumberPairEntry

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.CellEditable Gtk.CellEditable GObject.GInterface->Gtk.CellEditable Gtk.Editable Gtk.Editable GObject.GInterface->Gtk.Editable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GimpUi.NumberPairEntry GimpUi.NumberPairEntry Gtk.Buildable->Gtk.Widget Gtk.Entry Gtk.Entry Gtk.CellEditable->Gtk.Entry Gtk.Editable->Gtk.Entry Gtk.Entry->GimpUi.NumberPairEntry Gtk.Widget->Gtk.Entry

Subclasses:

None

Methods

Inherited:

Gtk.Entry (76), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.CellEditable (3), Gtk.Editable (13)

Structs:

Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new (separators, allow_simplification, min_valid_value, max_valid_value)

get_aspect ()

get_default_text ()

get_default_values ()

get_ratio ()

get_user_override ()

get_values ()

set_aspect (aspect)

set_default_text (string)

set_default_values (left, right)

set_ratio (ratio)

set_user_override (user_override)

set_values (left, right)

Virtual Methods

Inherited:

Gtk.Entry (14), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.CellEditable (3), Gtk.Editable (10)

Properties

Inherited:

Gtk.Entry (51), Gtk.Widget (39), Gtk.CellEditable (1)

Name

Type

Flags

Short Description

allow-simplification

bool

r/w

Whether to allow simplification

aspect

GimpUi.AspectType

r/w

The value as aspect

default-left-number

float

r/w

The default left number

default-right-number

float

r/w

The default right number

default-text

str

r/w

String to show when in automatic mode

left-number

float

r/w

The left number

max-valid-value

float

r/w

Maximum value valid when parsing input

min-valid-value

float

r/w

Minimum value valid when parsing input

ratio

float

r/w

The value as ratio

right-number

float

r/w

The right number

separators

str

r/w/co

A string of valid separators

user-override

bool

r/w

Whether the widget is in ‘user override’ mode

Style Properties

Inherited:

Gtk.Entry (4), Gtk.Widget (17)

Signals

Inherited:

Gtk.Entry (15), Gtk.Widget (69), GObject.Object (1), Gtk.CellEditable (2), Gtk.Editable (3)

Name

Short Description

numbers-changed

ratio-changed

Fields

Inherited:

Gtk.Entry (15), Gtk.Widget (69), GObject.Object (1), Gtk.CellEditable (2), Gtk.Editable (3)

Class Details

class GimpUi.NumberPairEntry(**kwargs)
Bases:

Gtk.Entry

Abstract:

No

Structure:

GimpUi.NumberPairEntryClass

A Gtk.Entry subclass to enter ratios.

classmethod new(separators, allow_simplification, min_valid_value, max_valid_value)
Parameters:
  • separators (str) – The allowed separators.

  • allow_simplification (bool) – Whether to do simplification on the entered term.

  • min_valid_value (float) – The minimum allowed result value.

  • max_valid_value (float) – The maximum allowed result value.

Returns:

The new GimpUi.NumberPairEntry widget.

Return type:

Gtk.Widget

Creates a new GimpUi.NumberPairEntry widget, which is a Gtk.Entry that accepts two numbers separated by a separator. Typical input example with a ‘x’ separator: “377x233”.

The widget supports simplification of the entered ratio when the input ends in ‘=’, if “allow-simplification” is True.

The “separators” property contains a string of characters valid as separators when parsing input. The first separator is used when displaying the current values.

It is possible to specify what range of values that shall be considered as valid when parsing user input, by changing “min-valid-value” and “max-valid-value”.

The first separator of separators is used to display the current value.

New in version 2.4.

get_aspect()
Returns:

The entry’s current aspect.

Return type:

GimpUi.AspectType

Gets the aspect of the ratio displayed by a GimpUi.NumberPairEntry.

New in version 2.4.

get_default_text()
Returns:

the string manually set to be shown, or None if values are shown in a normal fashion.

Return type:

str or None

New in version 2.4.

get_default_values()
Returns:

left:

Location to put the default left value, or None.

right:

Location to put the default right value, or None.

Return type:

(left: float, right: float)

New in version 2.4.

get_ratio()
Returns:

The ratio value.

Return type:

float

Retrieves the ratio of the numbers displayed by a GimpUi.NumberPairEntry.

New in version 2.4.

get_user_override()
Returns:

Whether or not the the widget is in user overridden mode.

Return type:

bool

New in version 2.4.

get_values()
Returns:

left:

Location to store the left number (may be None).

right:

Location to store the right number (may be None).

Return type:

(left: float, right: float)

Gets the numbers displayed by a GimpUi.NumberPairEntry.

New in version 2.4.

set_aspect(aspect)
Parameters:

aspect (GimpUi.AspectType) – The new aspect.

Sets the aspect of the ratio by swapping the left_number and right_number if necessary (or setting them to 1.0 in case that aspect is GimpUi.AspectType.SQUARE).

New in version 2.4.

set_default_text(string)
Parameters:

string (str) – Default string.

Causes the entry to show a given string when in automatic mode, instead of the default numbers. The only thing this does is making the GimpUi.NumberPairEntry showing this string, the internal state and API calls are not affected.

Set the default string to None to display default values as normal.

New in version 2.4.

set_default_values(left, right)
Parameters:
  • left (float) – Default left value in the entry.

  • right (float) – Default right value in the entry.

New in version 2.4.

set_ratio(ratio)
Parameters:

ratio (float) – Ratio to set in the widget.

Sets the numbers of the GimpUi.NumberPairEntry to have the desired ratio. If the new ratio is different than the previous ratio, the “ratio-changed” signal is emitted.

An attempt is made to convert the decimal number into a fraction with left_number and right_number < 1000.

New in version 2.4.

set_user_override(user_override)
Parameters:

user_override (bool) – True sets the entry in user overridden mode, False disables.

When the entry is not in user overridden mode, the values will change when the default values are changed. When in user overridden mode, setting default values will not affect the active values.

New in version 2.4.

set_values(left, right)
Parameters:
  • left (float) – Left number in the entry.

  • right (float) – Right number in the entry.

Forces setting the numbers displayed by a GimpUi.NumberPairEntry, ignoring if the user has set their own value. The state of user-override will not be changed.

New in version 2.4.

Signal Details

GimpUi.NumberPairEntry.signals.numbers_changed(number_pair_entry)
Signal Name:

numbers-changed

Flags:

RUN_FIRST

Parameters:

number_pair_entry (GimpUi.NumberPairEntry) – The object which received the signal

GimpUi.NumberPairEntry.signals.ratio_changed(number_pair_entry)
Signal Name:

ratio-changed

Flags:

RUN_FIRST

Parameters:

number_pair_entry (GimpUi.NumberPairEntry) – The object which received the signal

Property Details

GimpUi.NumberPairEntry.props.allow_simplification
Name:

allow-simplification

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether to allow simplification

GimpUi.NumberPairEntry.props.aspect
Name:

aspect

Type:

GimpUi.AspectType

Default Value:

GimpUi.AspectType.SQUARE

Flags:

READABLE, WRITABLE

The value as aspect

GimpUi.NumberPairEntry.props.default_left_number
Name:

default-left-number

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The default left number

GimpUi.NumberPairEntry.props.default_right_number
Name:

default-right-number

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The default right number

GimpUi.NumberPairEntry.props.default_text
Name:

default-text

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

String to show when in automatic mode

GimpUi.NumberPairEntry.props.left_number
Name:

left-number

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The left number

GimpUi.NumberPairEntry.props.max_valid_value
Name:

max-valid-value

Type:

float

Default Value:

1.7976931348623157e+308

Flags:

READABLE, WRITABLE

Maximum value valid when parsing input

GimpUi.NumberPairEntry.props.min_valid_value
Name:

min-valid-value

Type:

float

Default Value:

2.2250738585072014e-308

Flags:

READABLE, WRITABLE

Minimum value valid when parsing input

GimpUi.NumberPairEntry.props.ratio
Name:

ratio

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

The value as ratio

GimpUi.NumberPairEntry.props.right_number
Name:

right-number

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The right number

GimpUi.NumberPairEntry.props.separators
Name:

separators

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A string of valid separators

GimpUi.NumberPairEntry.props.user_override
Name:

user-override

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the widget is in ‘user override’ mode