Gizmos Widget Reference
Gizmos are custom dialog windows built in XML that Lua scripts can create. They provide interactive UIs for scripts — editing forms, data-bound views, multi-step workflows — anything beyond a simple alert() or query table.
You define the layout in XML, load it with gizmos.load(), then show it. The script handles events from the dialog’s widgets and can read or update their values at any time.
A complete example
This script creates a dialog with a text field and a button. When the user clicks the button, it reads the text field and shows a greeting.
–[[
@tool
@name Greeting
]]
local xml = [[
<dialog title="Greeting" width="300" height="150">
<vbox>
<hbox collapse="yes">
<label value="Name:" />
<text_field id="name_input" expand="horizontal" />
</hbox>
<hbox collapse="yes">
<spacer />
<button id="greet_btn" label="Greet" />
</hbox>
</vbox>
</dialog>
]]
gizmos.load(xml)
function greet_btn_action()
local name = Widget("name_input").text
alert("Hello, " .. name .. "!")
gizmos.close()
end
gizmos.show_modal()
Creating and showing a gizmo
The basic sequence is:
- Build an XML string describing the layout.
- Call gizmos.load(xml) to parse and create the widgets.
- Register any event handlers.
- Call gizmos.show() or gizmos.show_modal().
show() opens a non-modal dialog — the user can still interact with the main window. show_modal() blocks interaction with the main window until the dialog is closed.
The gizmos table
All gizmo functions live in the global gizmos table.
| Function | Description |
|---|
| gizmos.load(xml) | Parse XML and create the dialog |
| gizmos.show() | Show the dialog (non-modal) |
| gizmos.show_modal() | Show the dialog (modal — blocks main window) |
| gizmos.close() | Close the dialog |
| gizmos.call(id, method, …) | Call a method on a widget |
| gizmos.on(id, event_type, callback) | Register an event handler |
| gizmos.on_closing(callback) | Intercept window close (return true to allow) |
| gizmos.open_dialog(xml) | Open a child dialog at runtime |
gizmos.call() is the low-level way to interact with widgets. You pass the widget’s id, the method name, and any arguments. For example, gizmos.call("name_input", "text") reads the value, and gizmos.call("name_input", "text", "Alice") sets it.
gizmos.on_closing() lets you intercept the user pressing the close button. Return true to allow the close, or false to prevent it (useful for confirming unsaved changes).
Widget proxy shorthand
The Widget() function provides a convenient shorthand that avoids repeated calls to gizmos.call(). It returns a proxy object for the widget with the given id:
local w = Widget("my_field")
– Get a value (calls gizmos.call("my_field", "text"))
local value = w.text
– Set a value (calls gizmos.call("my_field", "text", "hello"))
w.text = "hello"
– Register an event handler
w.on_action = function()
– handle click
end
This is the recommended way to interact with widgets.
Event handling
There are two styles for handling events:
Convention-based
Define a global function named {id}_{event_type}. The gizmo framework finds it automatically:
function ok_btn_action()
gizmos.close()
end
function search_field_change()
– respond to text changes
end
Explicit registration
Use gizmos.on() or the Widget proxy:
gizmos.on("ok_btn", "action", function()
gizmos.close()
end)
– or equivalently:
Widget("ok_btn").on_action = function()
gizmos.close()
end
Event types
| Event | Fires when |
|---|
| "action" | Button clicked, Enter pressed, item double-clicked |
| "change" | Value or selection changed |
Common attributes
These attributes are available on all widgets:
| Attribute | Values | Purpose |
|---|
| id | any string | Unique identifier used by scripts to interact with the widget |
| expand | "horizontal", "vertical", "both", "no" | Controls how the widget grows to fill available space |
| enabled | "true", "false" | Whether the widget accepts input |
| visible | "true", "false" | Whether the widget is shown |
Common methods
These methods are available on all widgets via gizmos.call() or the Widget proxy:
| Method | Get/Set | Description |
|---|
| enabled | get/set | Enable or disable the widget (boolean) |
| visible | get/set | Show or hide the widget (boolean) |
| focus | set | Give keyboard focus to the widget |
| tooltip | set | Set the tooltip text |
Dialog and frame attributes
The ‘<dialog>‘ element
The root element for gizmos embedded in Pedigree Forge scripts:
| Attribute | Description |
|---|
| title | Window title |
| width | Initial width in pixels |
| height | Initial height in pixels |
| modal | "true" or "false" |
| default_button | id of the button activated by Enter |
| focus | id of the widget that receives initial focus |
The ‘<gizmos>‘ wrapper
An alternative root element that supports additional modes:
| Attribute | Values | Description |
|---|
| mode | "dialog" (default), "app" | "dialog" for Pedigree Forge scripts; "app" for standalone |
| theme | see below | Visual theme |
Available themes: light, dark, light_alt, dark_alt, high_contrast, fluent, sepia, parchment, forest, midnight, ocean, lavender, slate, autumn.
Layout widgets
‘<vbox>‘ — Vertical box
Arranges children in a vertical stack.
| Attribute | Values | Description |
|---|
| expand | "horizontal", "vertical", "both", "no" | Growth behaviour |
| align | "left", "centre", "right" | Horizontal alignment of children |
| collapse | "yes" | Makes the container fixed-height |
‘<hbox>‘ — Horizontal box
Arranges children in a horizontal row.
| Attribute | Values | Description |
|---|
| expand | "horizontal", "vertical", "both", "no" | Growth behaviour |
| align | "top", "middle", "bottom" | Vertical alignment of children |
| collapse | "yes" | Makes the container fixed-width |
‘<grid>‘ — Grid layout
Arranges children in a grid. Children fill cells left-to-right, top-to-bottom.
| Attribute | Values | Description |
|---|
| columns | integer | Number of columns |
| expand | "horizontal", "vertical", "both", "no" | Growth behaviour |
| collapse | "yes" | Fixed size |
‘<panel>‘ — Panel container
A general-purpose container. Also used as tab pages inside <tabs> (see below).
| Attribute | Values | Description |
|---|
| name | text | Label shown on the tab when used inside <tabs> |
| expand | "horizontal", "vertical", "both", "no" | Growth behaviour |
‘<spacer>‘ — Flexible space
Pushes siblings apart by consuming available space. Takes no attributes beyond the common ones.
‘<strut>‘ — Fixed-size spacer
Inserts a fixed gap.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
‘<field_sep>‘ — Field separator
A horizontal rule, optionally with a title.
| Attribute | Values | Description |
|---|
| title | text | Optional heading text |
‘<zbox>‘ — Stacked layout
Stacks all children on top of each other. Only one child is visible at a time — useful for wizard-style step-by-step interfaces.
| Method | Get/Set | Description |
|---|
| show | set | Show child by index (0-based) |
‘<collapsible_panel>‘ — Expandable section
A section with a clickable header that expands or collapses its content.
| Attribute | Values | Description |
|---|
| label | text | Header text |
| collapsed | "true", "false" | Initial state |
| border | "true", "false" | Draw a border |
| Event | Fires when |
|---|
| action | Panel expanded or collapsed |
| Method | Get/Set | Description |
|---|
| collapsed | get/set | Collapsed state (boolean) |
‘<split_pane>‘ — Resizable split
Splits its area into two resizable panels.
| Attribute | Values | Description |
|---|
| orientation | "horizontal", "vertical" | Split direction |
| ratio | number (0.0 to 1.0) | Initial split ratio |
| expand | "horizontal", "vertical", "both", "no" | Growth behaviour |
| Method | Get/Set | Description |
|---|
| mode | get/set | Split mode |
| best_fit | set | Auto-fit to content |
‘<tabs>‘ — Tab container
Contains <panel> children, each shown as a tab page. The name attribute on each <panel> becomes the tab label.
<tabs id="my_tabs">
<panel name="General">
<!– general content –>
</panel>
<panel name="Advanced">
<!– advanced content –>
</panel>
</tabs>
| Event | Fires when |
|---|
| change | Tab selection changes |
| Method | Get/Set | Description |
|---|
| selected_tab | get | Index of the selected tab (0-based) |
| set_current_tab | set | Switch to a tab by index |
Input widgets
‘<button>‘ — Push button
| Attribute | Values | Description |
|---|
| label | text | Button text |
| tooltip | text | Tooltip |
| command | text | Built-in command name |
| command_for | text | Target widget id for the command |
| Event | Fires when |
|---|
| action | Button clicked |
| Method | Get/Set | Description |
|---|
| text | get/set | Button label |
‘<label>‘ — Text label
| Attribute | Values | Description |
|---|
| value | text | Label text |
| tooltip | text | Tooltip |
| Method | Get/Set | Description |
|---|
| text | get/set | Label text |
| clear | set | Clear the text |
‘<check>‘ — Checkbox
| Attribute | Values | Description |
|---|
| label | text | Checkbox label |
| checked | "true", "false" | Initial state |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Checkbox toggled |
| Method | Get/Set | Description |
|---|
| checked | get/set | Checked state (boolean) |
| text | get/set | Label text |
‘<radio>‘ — Radio button
Radio buttons with the same group value are mutually exclusive.
| Attribute | Values | Description |
|---|
| label | text | Radio button label |
| group | text | Group name |
| checked | "true", "false" | Initial state |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Radio button selected |
| Method | Get/Set | Description |
|---|
| checked | get/set | Selected state (boolean) |
| text | get/set | Label text |
‘<text_field>‘ — Single-line text input
| Attribute | Values | Description |
|---|
| value | text | Initial text |
| cue | text | Placeholder text shown when empty |
| tooltip | text | Tooltip |
| expand | "horizontal" | Growth behaviour |
| Event | Fires when |
|---|
| action | Enter pressed |
| change | Text edited |
| Method | Get/Set | Description |
|---|
| text | get/set | Field text |
| cue | set | Placeholder text |
| clear | set | Clear the text |
| valid | get | Whether the current value passes validation |
‘<text_area>‘ — Multi-line text input
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| value | text | Initial text |
| read_only | "true", "false" | Prevent editing |
| no_return | "true", "false" | Suppress Enter key (fires action instead) |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Text edited |
| Method | Get/Set | Description |
|---|
| text | get/set | Full text content |
| clear | set | Clear all text |
| scroll_to_end | set | Scroll to the bottom |
| selected_text | get | Currently selected text |
| replace_selection | set | Replace the selection with new text |
| selection_start | get | Start index of selection |
| selection_end | get | End index of selection |
‘<choice>‘ — Dropdown list
A non-editable dropdown. Items are defined in XML as children:
<choice id="colour">
<item label="Red" />
<item label="Green" />
<item label="Blue" />
</choice>
| Attribute | Values | Description |
|---|
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Selection changes |
| Method | Get/Set | Description |
|---|
| selected | get | Index of selected item (0-based) |
| selected_text | get | Text of selected item |
| select | set | Select item by index |
| append | set | Add an item |
| clear | set | Remove all items |
| count | get | Number of items |
‘<combo>‘ — Editable dropdown
Like <choice>, but the user can also type a custom value.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| tooltip | text | Tooltip |
Children: <item label="…"> elements.
| Event | Fires when |
|---|
| change | Text or selection changes |
| Method | Get/Set | Description |
|---|
| text | get/set | Current text (typed or selected) |
| append | set | Add an item |
| clear | set | Remove all items |
‘<list>‘ — List box
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| tooltip | text | Tooltip |
Children: <item label="…" value="…"> elements.
| Event | Fires when |
|---|
| action | Item double-clicked |
| change | Selection changes |
| Method | Get/Set | Description |
|---|
| selected | get | Index of selected item |
| selected_text | get | Text of selected item |
| select | set | Select item by index |
| append | set | Add an item |
| remove | set | Remove an item by index |
| clear | set | Remove all items |
| count | get | Number of items |
| item_text | get | Text of item at index |
| item_value | get | Value of item at index |
‘<table>‘ — Data table
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| no_headers | "true", "false" | Hide column headers |
| auto_size_columns | "true", "false" | Auto-fit column widths |
Columns are defined as children:
<table id="results" width="400" height="200">
<column text="Name" width="200" />
<column text="Born" width="100" right_align="true" />
</table>
| Event | Fires when |
|---|
| action | Row double-clicked |
| change | Selection changes |
| Method | Get/Set | Description |
|---|
| add_column | set | Add a column (text, width) |
| add_row | set | Add a row (returns row index) |
| cell_text | get/set | Get or set text at (row, column) |
| selected_row | get | Index of selected row |
| row_count | get | Number of rows |
| column_count | get | Number of columns |
| clear_rows | set | Remove all rows |
| delete_row | set | Remove a row by index |
‘<spinner>‘ — Integer spinner
| Attribute | Values | Description |
|---|
| min | integer | Minimum value |
| max | integer | Maximum value |
| value | integer | Initial value |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Value changes |
| Method | Get/Set | Description |
|---|
| value | get/set | Current value |
| range | set | Set min and max (two arguments) |
‘<numeric_spinner>‘ — Floating-point spinner
| Attribute | Values | Description |
|---|
| min | number | Minimum value |
| max | number | Maximum value |
| step | number | Increment per click |
| units | text | Units label (e.g. "mm", "%") |
| value | number | Initial value |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Value changes |
| Method | Get/Set | Description |
|---|
| value | get/set | Current value |
| range | set | Set min and max (two arguments) |
| step | get/set | Increment per click |
‘<slider>‘ — Slider
| Attribute | Values | Description |
|---|
| min | integer | Minimum value |
| max | integer | Maximum value |
| value | integer | Initial value |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Value changes |
| Method | Get/Set | Description |
|---|
| value | get/set | Current value |
| range | set | Set min and max (two arguments) |
‘<range_slider>‘ — Range slider
A slider with two thumbs for selecting a range.
| Attribute | Values | Description |
|---|
| min | integer | Minimum value |
| max | integer | Maximum value |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Either thumb moves |
| Method | Get/Set | Description |
|---|
| low | get/set | Lower bound value |
| high | get/set | Upper bound value |
| set_range | set | Set both bounds at once |
‘<toggle_switch>‘ — Toggle switch
| Attribute | Values | Description |
|---|
| label | text | Switch label |
| checked | "true", "false" | Initial state |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Switch toggled |
| Method | Get/Set | Description |
|---|
| checked | get/set | On/off state (boolean) |
| text | get/set | Label text |
‘<search_box>‘ — Search input
A text field with a search icon and clear button.
| Attribute | Values | Description |
|---|
| cue | text | Placeholder text |
| width | integer | Width in pixels |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Enter pressed |
| change | Text edited |
| Method | Get/Set | Description |
|---|
| text | get/set | Search text |
| clear | set | Clear the text |
| cue | set | Placeholder text |
‘<password_field>‘ — Password input
Text is masked. Otherwise behaves like <text_field>.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| change | Text edited |
| Method | Get/Set | Description |
|---|
| text | get/set | Field text |
| clear | set | Clear the text |
‘<tri_check>‘ — Three-state checkbox
Cycles through three states: unchecked (false), checked (true), and indeterminate (nil).
| Attribute | Values | Description |
|---|
| label | text | Checkbox label |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Checkbox toggled |
| Method | Get/Set | Description |
|---|
| value | get/set | Current state (false, true, or nil) |
| text | get/set | Label text |
‘<segmented_control>‘ — Segmented button bar
A row of mutually exclusive buttons. Items defined as children:
<segmented_control id="view_mode">
<item label="List" />
<item label="Grid" />
<item label="Detail" />
</segmented_control>
| Event | Fires when |
|---|
| change | Selection changes |
| Method | Get/Set | Description |
|---|
| selected | get/set | Index of selected segment (0-based) |
‘<link>‘ — Clickable link
| Attribute | Values | Description |
|---|
| value | text | Link text |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Link clicked |
| Method | Get/Set | Description |
|---|
| text | get/set | Link text |
‘<progress>‘ — Progress bar
| Attribute | Values | Description |
|---|
| value | number (0.0 to 1.0) | Initial progress |
| Method | Get/Set | Description |
|---|
| value | get/set | Progress (0.0 to 1.0) |
| marquee | set | Enable indeterminate (animated) mode |
Display widgets
‘<text_block>‘ — Wrapped text block
Displays read-only text that wraps within a given width.
| Attribute | Values | Description |
|---|
| value | text | Text content |
| width | integer | Width in pixels |
| Method | Get/Set | Description |
|---|
| text | get/set | Text content |
| clear | set | Clear the text |
‘<image>‘ — Image display
| Attribute | Values | Description |
|---|
| src | path | Image file path |
| width | integer | Display width |
| height | integer | Display height |
| Method | Get/Set | Description |
|---|
| set | set | Set image by file path |
‘<icon_button>‘ — Icon button
A button that displays an icon rather than text.
| Attribute | Values | Description |
|---|
| text | text | Icon glyph or label |
| toggle | "true", "false" | Whether the button toggles on/off |
| tooltip | text | Tooltip |
| Event | Fires when |
|---|
| action | Button clicked |
| Method | Get/Set | Description |
|---|
| latched | get/set | Toggle state (boolean, only for toggle buttons) |
| text | get/set | Icon or label text |
‘<badge>‘ — Badge indicator
A small indicator, typically overlaid on another widget.
| Attribute | Values | Description |
|---|
| style | "dot", "count", "label" | Badge style |
| count | integer | Count to display (for "count" style) |
| text | text | Label text (for "label" style) |
| Method | Get/Set | Description |
|---|
| count | get/set | Count value |
| text | get/set | Label text |
Data widgets
‘<tree>‘ — Tree view
A hierarchical tree. Items are added from Lua code rather than XML.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| Event | Fires when |
|---|
| action | Item double-clicked |
| change | Selection changes |
| Method | Get/Set | Description |
|---|
| add | set | Add item: add(parent_data, label, data) |
| add_front | set | Add item at the front: add_front(parent_data, label, data) |
| selected | get | Data value of selected item |
| selected_text | get | Label of selected item |
| clear | set | Remove all items |
| remove | set | Remove item by data value |
| set_bold | set | Set bold state for an item |
| set_image | set | Set an image on an item |
| get_label | get | Get the label of an item by data value |
Tip — Use nil or 0 as parent_data to add root-level items.
‘<editable_table>‘ — Editable table
Like <table>, but cells can be edited directly.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| row_lines | "true", "false" | Show horizontal lines between rows |
Columns are defined as children: <column text="…" width="…">.
| Event | Fires when |
|---|
| action | Row double-clicked |
| change | Cell edited |
| Method | Get/Set | Description |
|---|
| add_row | set | Add a row |
| cell_text | get/set | Get or set text at (row, column) |
| selected_row | get | Index of selected row |
| selected_col | get | Index of selected column |
| row_count | get | Number of rows |
| clear_rows | set | Remove all rows |
| delete_row | set | Remove a row by index |
‘<property_grid>‘ — Property grid
A two-column grid of named properties, grouped by category. Properties are added from Lua code.
| Attribute | Values | Description |
|---|
| width | integer | Width in pixels |
| height | integer | Height in pixels |
| Event | Fires when |
|---|
| change | A property value changes |
| Method | Get/Set | Description |
|---|
| add_category | set | Add a category heading |
| add_text_property | set | Add a text property: add_text_property(category, name, value) |
| add_check_property | set | Add a checkbox property: add_check_property(category, name, checked) |
| add_choice_property | set | Add a dropdown property: add_choice_property(category, name, options, selected) |
| property_value | get | Get the value of a text or choice property by name |
| property_checked | get | Get the checked state of a checkbox property by name |
Data-bound widgets
These widgets connect directly to the genealogy database. They automatically load data when shown and save changes back when edited.
‘<bound_text_field>‘
An editable text field bound to a database field.
| Attribute | Values | Description |
|---|
| path | data expression | Required. The data path (e.g. "person.surname") |
| record | record ID | Optional. Specific record (e.g. "I1"). Defaults to the current selection |
| completer | see below | Auto-completion source |
| validator | see below | Validation rule |
When the path’s data type is a date, place, age, trade, or similar structured type, the field automatically includes a helper button with an entry assistant. See the entry assistants table below for details.
Supports the same methods as <text_field>.
‘<bound_label>‘
A read-only label bound to a database field.
| Attribute | Values | Description |
|---|
| path | data expression | Required. The data path |
| record | record ID | Optional. Specific record |
Supports the same methods as <label>.
Query-bound widgets
These widgets are populated by a query language query string.
‘<bound_table>‘
A read-only table populated from a query.
| Attribute | Values | Description |
|---|
| query | Query string | The query to execute |
‘<bound_edit_table>‘
An editable table populated from a query. Edits are written back to the database. Date, place, and age columns automatically receive helper buttons with entry assistants.
| Attribute | Values | Description |
|---|
| query | Query string | The query to execute |
‘<bound_detail_grid>‘
A detail view populated from a query, displaying results as a property-style grid rather than a table. Date, place, and age properties automatically receive helper buttons with entry assistants.
| Attribute | Values | Description |
|---|
| query | Query string | The query to execute |
Completers and validators
Bound text fields automatically receive a completer and validator based on the type of data they are bound to:
| Field type | Completer | Validator |
|---|
| Date | – | date |
| Place name | place | place |
| Person name | names | – |
| Trade | trades | – |
| Age | – | – |
| Time | – | – |
| Address | – | – |
| Cause | – | – |
You can override these defaults using the completer and validator attributes. Available values: place, names, trades, date, none.
Setting completer="none" or validator="none" disables the auto-assigned behaviour.
Entry assistants
Some field types also receive a helper button that opens an entry assistant dialog. Press F2 or click the button to open it.
| Field type | Icon | Assistant |
|---|
| Date | Calendar | Date entry assistant |
| Place name | Map pin | Place entry assistant |
| Age | Clock | Age entry assistant |
| Trade | Hammer | (coming soon) |
| Time | Clock | (coming soon) |
| Address | Building | (coming soon) |
| Cause | Medical notes | (coming soon) |
Entry assistants appear automatically on <bound_text_field>, <bound_edit_table>, and <bound_detail_grid> widgets when their data type matches the table above.