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);

gp_widget *gp_widget_button_new2(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 type modification
enum gp_widget_button_type gp_widget_button_type_get(gp_widget *self);

void gp_widget_button_type_set(gp_widget *self, enum gp_widget_button_type type);

Functions to get and set button type during the runtime. The alignment is masked out of the return value from the get function.

Button types

Button types

Example buttons with type and label

Button with type and label

Table 1. Button JSON attributes
Attribute Type Default Description



Button label




Button type




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


Emitted on button press.