GimpUi.SizeEntry

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.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GimpUi.SizeEntry GimpUi.SizeEntry Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Grid Gtk.Grid Gtk.Container->Gtk.Grid Gtk.Grid->GimpUi.SizeEntry Gtk.Orientable->Gtk.Grid Gtk.Widget->Gtk.Container

Subclasses:

None

Methods

Inherited:

Gtk.Grid (21), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Orientable (2)

Structs:

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

class

new (number_of_fields, unit, unit_format, menu_show_pixels, menu_show_percent, show_refval, spinbutton_width, update_policy)

add_field (value_spinbutton, refval_spinbutton)

attach_label (text, row, column, alignment)

get_help_widget (field)

get_n_fields ()

get_refval (field)

get_unit ()

get_unit_combo ()

get_update_policy ()

get_value (field)

grab_focus ()

set_activates_default (setting)

set_pixel_digits (digits)

set_refval (field, refval)

set_refval_boundaries (field, lower, upper)

set_refval_digits (field, digits)

set_resolution (field, resolution, keep_size)

set_size (field, lower, upper)

set_unit (unit)

set_value (field, value)

set_value_boundaries (field, lower, upper)

show_unit_menu (show)

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

Properties

Inherited:

Gtk.Grid (5), Gtk.Container (3), Gtk.Widget (39), Gtk.Orientable (1)

Child Properties

Inherited:

Gtk.Grid (4)

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Short Description

refval-changed

unit-changed

value-changed

Fields

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Class Details

class GimpUi.SizeEntry(**kwargs)
Bases:

Gtk.Grid

Abstract:

No

Structure:

GimpUi.SizeEntryClass

This widget is used to enter pixel distances/sizes and resolutions.

You can specify the number of fields the widget should provide. For each field automatic mappings are performed between the field’s “reference value” and its “value”.

There is a GimpUi.UnitComboBox right of the entry fields which lets you specify the Gimp.Unit of the displayed values.

For each field, there can be one or two Gtk.SpinButton's to enter “value” and “reference value”. If you specify show_refval as False in GimpUi.SizeEntry.new() there will be only one Gtk.SpinButton and the GimpUi.UnitComboBox will contain an item for selecting Gimp.UnitID.PIXEL.

The “reference value” is either of Gimp.UnitID.PIXEL or dpi, depending on which GimpUi.SizeEntryUpdatePolicy you specify in GimpUi.SizeEntry.new(). The “value” is either the size in pixels mapped to the size in a real-world-unit (see Gimp.Unit) or the dpi value mapped to pixels per real-world-unit.

classmethod new(number_of_fields, unit, unit_format, menu_show_pixels, menu_show_percent, show_refval, spinbutton_width, update_policy)
Parameters:
Returns:

A Pointer to the new GimpUi.SizeEntry widget.

Return type:

Gtk.Widget

Creates a new GimpUi.SizeEntry widget.

To have all automatic calculations performed correctly, set up the widget in the following order:

GimpUi.SizeEntry.new()

(for each additional input field) GimpUi.SizeEntry.add_field()

GimpUi.SizeEntry.set_unit()

For each input field:

GimpUi.SizeEntry.set_resolution()

GimpUi.SizeEntry.set_refval_boundaries() (or GimpUi.SizeEntry.set_value_boundaries())

GimpUi.SizeEntry.set_size()

GimpUi.SizeEntry.set_refval() (or GimpUi.SizeEntry.set_value())

The GimpUi.SizeEntry is derived from Gtk.Grid and will have an empty border of one cell width on each side plus an empty column left of the GimpUi.UnitComboBox to allow the caller to add labels or a GimpUi.ChainButton.

add_field(value_spinbutton, refval_spinbutton)
Parameters:
  • value_spinbutton (Gtk.SpinButton) – The spinbutton to display the field’s value.

  • refval_spinbutton (Gtk.SpinButton or None) – The spinbutton to display the field’s reference value.

Adds an input field to the GimpUi.SizeEntry.

The new input field will have the index 0. If you specified show_refval as True in GimpUi.SizeEntry.new() you have to pass an additional Gtk.SpinButton to hold the reference value. If show_refval was False, refval_spinbutton will be ignored.

attach_label(text, row, column, alignment)
Parameters:
  • text (str) – The text of the label.

  • row (int) – The row where the label will be attached.

  • column (int) – The column where the label will be attached.

  • alignment (float) – The horizontal alignment of the label.

Returns:

A pointer to the new Gtk.Label widget.

Return type:

Gtk.Widget

Attaches a Gtk.Label to the GimpUi.SizeEntry (which is a Gtk.Grid).

get_help_widget(field)
Parameters:

field (int) – the index of the widget you want to get a pointer to

Returns:

a Gtk.Widget pointer that you can attach a tooltip to.

Return type:

Gtk.Widget

You shouldn’t fiddle with the internals of a GimpUi.SizeEntry but if you want to set tooltips using GimpUi.help_set_help_data() you can use this function to get a pointer to the spinbuttons.

get_n_fields()
Return type:

int

get_refval(field)
Parameters:

field (int) – The index of the field you want to know the reference value of.

Returns:

The reference value of the chosen field.

Return type:

float

Returns the reference value for field # field of the GimpUi.SizeEntry.

The reference value is either a distance in pixels or a resolution in dpi, depending on which GimpUi.SizeEntryUpdatePolicy you chose in GimpUi.SizeEntry.new().

get_unit()
Returns:

The sizeentry’s unit.

Return type:

Gimp.Unit

Returns the Gimp.Unit the user has selected in the GimpUi.SizeEntry's GimpUi.UnitComboBox.

get_unit_combo()
Returns:

the size entry’s GimpUi.UnitComboBox.

Return type:

GimpUi.UnitComboBox

get_update_policy()
Return type:

GimpUi.SizeEntryUpdatePolicy

get_value(field)
Parameters:

field (int) – The index of the field you want to know the value of.

Returns:

The value of the chosen field.

Return type:

float

Returns the value of field # field of the GimpUi.SizeEntry.

The value returned is a distance or resolution in the Gimp.Unit the user has selected in the GimpUi.SizeEntry's GimpUi.UnitComboBox.

NOTE: In most cases you won’t be interested in this value because the GimpUi.SizeEntry's purpose is to shield the programmer from unit calculations. Use GimpUi.SizeEntry.get_refval() instead.

grab_focus()

This function is rather ugly and just a workaround for the fact that it’s impossible to implement Gtk.Widget.grab_focus() for a Gtk.Grid (is this actually true after the Table->Grid conversion?).

set_activates_default(setting)
Parameters:

setting (bool) – True to activate window’s default widget on Enter keypress

Iterates over all entries in the GimpUi.SizeEntry and calls Gtk.Entry.set_activates_default() on them.

New in version 2.4.

set_pixel_digits(digits)
Parameters:

digits (int) – the number of digits to display for a pixel size

This function allows you set up a GimpUi.SizeEntry so that sub-pixel sizes can be entered.

set_refval(field, refval)
Parameters:
  • field (int) – The index of the field you want to set the reference value for.

  • refval (float) – The new reference value for field.

Sets the reference value for field # field of the GimpUi.SizeEntry.

The refval passed is either a distance in pixels or a resolution in dpi, depending on which GimpUi.SizeEntryUpdatePolicy you chose in GimpUi.SizeEntry.new().

set_refval_boundaries(field, lower, upper)
Parameters:
  • field (int) – The index of the field you want to set the reference value boundaries for.

  • lower (float) – The new lower boundary of the reference value of the chosen field.

  • upper (float) – The new upper boundary of the reference value of the chosen field.

Limits the range of possible reference values which can be entered in field # field of the GimpUi.SizeEntry.

The current reference value of the field will be clamped to fit in the field's new boundaries.

set_refval_digits(field, digits)
Parameters:
  • field (int) – The index of the field you want to set the reference value for.

  • digits (int) – The new number of decimal digits for the Gtk.SpinButton which displays field's reference value.

Sets the decimal digits of field # field of the GimpUi.SizeEntry to digits.

If you don’t specify this value explicitly, the reference value’s number of digits will equal to 0 for GimpUi.SizeEntryUpdatePolicy.SIZE and to 2 for GimpUi.SizeEntryUpdatePolicy.RESOLUTION.

set_resolution(field, resolution, keep_size)
Parameters:
  • field (int) – The index of the field you want to set the resolution for.

  • resolution (float) – The new resolution (in dpi) for the chosen field.

  • keep_size (bool) – True if the field's size in pixels should stay the same. False if the field's size in units should stay the same.

Sets the resolution (in dpi) for field # field of the GimpUi.SizeEntry.

The resolution passed will be clamped to fit in [Gimp.MIN_RESOLUTION..:obj:Gimp.MAX_RESOLUTION].

This function does nothing if the GimpUi.SizeEntryUpdatePolicy specified in GimpUi.SizeEntry.new() doesn’t equal to GimpUi.SizeEntryUpdatePolicy.SIZE.

set_size(field, lower, upper)
Parameters:
  • field (int) – The index of the field you want to set the size for.

  • lower (float) – The reference value which will be treated as 0%.

  • upper (float) – The reference value which will be treated as 100%.

Sets the pixel values for field # field of the GimpUi.SizeEntry which will be treated as 0% and 100%.

These values will be used if you specified menu_show_percent as True in GimpUi.SizeEntry.new() and the user has selected Gimp.UnitID.PERCENT in the GimpUi.SizeEntry's GimpUi.UnitComboBox.

This function does nothing if the GimpUi.SizeEntryUpdatePolicy specified in GimpUi.SizeEntry.new() doesn’t equal to GimpUi.SizeEntryUpdatePolicy.SIZE.

set_unit(unit)
Parameters:

unit (Gimp.Unit) – The new unit.

Sets the GimpUi.SizeEntry's unit. The reference value for all fields will stay the same but the value in units or pixels per unit will change according to which GimpUi.SizeEntryUpdatePolicy you chose in GimpUi.SizeEntry.new().

set_value(field, value)
Parameters:
  • field (int) – The index of the field you want to set a value for.

  • value (float) – The new value for field.

Sets the value for field # field of the GimpUi.SizeEntry.

The value passed is treated to be a distance or resolution in the Gimp.Unit the user has selected in the GimpUi.SizeEntry's GimpUi.UnitComboBox.

NOTE: In most cases you won’t be interested in this value because the GimpUi.SizeEntry's purpose is to shield the programmer from unit calculations. Use GimpUi.SizeEntry.set_refval() instead.

set_value_boundaries(field, lower, upper)
Parameters:
  • field (int) – The index of the field you want to set value boundaries for.

  • lower (float) – The new lower boundary of the value of the chosen field.

  • upper (float) – The new upper boundary of the value of the chosen field.

Limits the range of possible values which can be entered in field # field of the GimpUi.SizeEntry.

The current value of the field will be clamped to fit in the field's new boundaries.

NOTE: In most cases you won’t be interested in this function because the GimpUi.SizeEntry's purpose is to shield the programmer from unit calculations. Use GimpUi.SizeEntry.set_refval_boundaries() instead. Whatever you do, don’t mix these calls. A size entry should either be clamped by the value or the reference value.

show_unit_menu(show)
Parameters:

show (bool) – Boolean

Controls whether a unit menu is shown in the size entry. If show is True, the menu is shown; otherwise it is hidden.

New in version 2.4.

Signal Details

GimpUi.SizeEntry.signals.refval_changed(size_entry)
Signal Name:

refval-changed

Flags:

RUN_FIRST

Parameters:

size_entry (GimpUi.SizeEntry) – The object which received the signal

GimpUi.SizeEntry.signals.unit_changed(size_entry)
Signal Name:

unit-changed

Flags:

RUN_FIRST

Parameters:

size_entry (GimpUi.SizeEntry) – The object which received the signal

GimpUi.SizeEntry.signals.value_changed(size_entry)
Signal Name:

value-changed

Flags:

RUN_FIRST

Parameters:

size_entry (GimpUi.SizeEntry) – The object which received the signal