Navigation C API Pages Python bindings Applications

Button widget

Button is a widget that emits event when pressed, buttons can have label or type or both, see below.

A button widget

Button widget

Button attributes can be accessed as widget->button.

Button widget constructor
gp_widget *gp_widget_button_new(const char *label,
                                enum gp_widget_button_type btype,
                                int (*on_event)(gp_widget_event *ev),
                                void *priv);

Creates a button widget, at least one of the label or btype has to be set.

If button type is set the button will be rendered with a small picture that describes the action, e.g. floppy for GP_BUTTON_SAVE. If label is also set the button will have both icon and label. The type picture will be positioned either on the left or on the right side of the label and the default position could be overriden by bit-or of GP_BUTTON_TEXT_LEFT or GP_BUTTON_TEXT_RIGHT with the button type.

Buttons with just a label are created with btype set to GP_BUTTON_LABEL which is equal to 0.

Button types

Button types

Example buttons with type and label

Button with type and label

Table 1. Button JSON attributes
Attribute Type Default Description

label

string

Button label

btype

string

"label"

Button type

text_align

string

depends

Button text align

The text_align can be either left or right and the default value depends on the btype.

Table 2. Button widget events
Widget event value Description

0

Emitted on button press.