Core Module

Main GuiBuilder Class

class vibegui.GuiBuilder(config_path=None, config_dict=None, backend=None)[source]

Bases: object

Unified GUI builder that automatically selects the appropriate backend.

This class provides a consistent interface that works with Qt, wxPython, tkinter, and GTK backends, automatically selecting the available backend or using the one specified via set_backend().

Parameters:
  • config_path (Optional[str])

  • config_dict (Optional[Dict[str, Any]])

  • backend (Optional[str])

backend

The currently active backend name

Type:

str

builder

The underlying backend-specific builder instance

Example

Simplest usage - create and run immediately:

>>> from vibegui import GuiBuilder
>>> GuiBuilder.create_and_run('config.json')

Force a specific backend:

>>> from vibegui import set_backend, GuiBuilder
>>> set_backend('tk')
>>> GuiBuilder.create_and_run('config.json')

For Qt backend, create QApplication first:

>>> from vibegui import GuiBuilder
>>> from qtpy.QtWidgets import QApplication
>>> import sys
>>> app = QApplication(sys.argv)
>>> gui = GuiBuilder('config.json')
>>> gui.show()
>>> app.exec()

For tkinter backend:

>>> from vibegui import set_backend, GuiBuilder
>>> set_backend('tk')
>>> gui = GuiBuilder('config.json')
>>> gui.show()
>>> gui.run()

Use with configuration dictionary:

>>> config = {"window": {"title": "My App"}, "fields": [...]}
>>> GuiBuilder.create_and_run(config_dict=config)
show()[source]

Show the GUI window.

Return type:

None

hide()[source]

Hide the GUI window.

Return type:

None

get_form_data()[source]

Get all form data as a dictionary.

Return type:

Dict[str, Any]

set_form_data(data)[source]

Set form data from a dictionary.

Parameters:

data (Dict[str, Any])

Return type:

None

clear_form()[source]

Clear all form fields.

Return type:

None

get_field_value(field_name)[source]

Get the value of a specific field.

Parameters:

field_name (str) – Name of the field to get the value from

Returns:

The current value of the field, or None if field doesn’t exist

Return type:

Any

set_field_value(field_name, value)[source]

Set the value of a specific field.

Parameters:
  • field_name (str) – Name of the field to set

  • value (Any) – Value to set for the field

Returns:

True if the value was set successfully, False otherwise

Return type:

bool

set_submit_callback(callback)[source]

Set a callback function to be called when the form is submitted.

Parameters:

callback (Callable)

Return type:

None

set_cancel_callback(callback)[source]

Set a callback function to be called when the form is cancelled.

Parameters:

callback (Callable)

Return type:

None

set_custom_button_callback(button_name, callback)[source]

Set a callback function to be called when a custom button is clicked.

Parameters:
Return type:

None

remove_custom_button_callback(button_name)[source]

Remove a custom button callback.

Parameters:

button_name (str)

Return type:

None

get_custom_button_names()[source]

Get a list of all custom button names from the configuration.

Return type:

list[str]

enable_field(field_name, enabled=True)[source]

Enable or disable a specific field.

Parameters:
Return type:

None

show_field(field_name, visible=True)[source]

Show or hide a specific field.

Parameters:
Return type:

None

load_data_from_file(data_file_path)[source]

Load form data from a JSON file and populate the GUI.

Parameters:

data_file_path (str)

Return type:

bool

load_data_from_dict(data)[source]

Load form data from a dictionary and populate the GUI.

Parameters:

data (Dict[str, Any])

Return type:

bool

save_data_to_file(data_file_path, include_empty=True)[source]

Save current form data to a JSON file.

Parameters:
  • data_file_path (str)

  • include_empty (bool)

Return type:

bool

run()[source]

Run the GUI application (start the main loop).

Return type:

None

close()[source]

Close the GUI application.

Return type:

None

__getattr__(name)[source]

Forward attribute access to the underlying builder.

This allows access to backend-specific attributes like Qt Signals (fieldChanged, formSubmitted, formCancelled).

Parameters:

name (str)

Return type:

Any

static create_and_run(config_path=None, config_dict=None, backend=None)[source]

Create and run a GUI application with automatic backend detection.

Parameters:
  • config_path (str | None) – Path to JSON configuration file

  • config_dict (Dict[str, Any] | None) – Configuration dictionary (alternative to config_path)

  • backend (str | None) – Force a specific backend (‘qt’, ‘wx’, or ‘tk’). If None, auto-detects.

Returns:

GuiBuilder instance

Return type:

GuiBuilder

Backend Management

Backend detection and selection for vibegui. Supports Qt (via qtpy), wxPython, tkinter, and GTK backends.

class vibegui.backend.BackendManager[source]

Bases: object

Manages GUI backend selection and availability.

SUPPORTED_BACKENDS = ['qt', 'wx', 'tk', 'gtk', 'flet']
DEFAULT_BACKEND = 'qt'
get_available_backends()[source]

Get list of available backends.

Return type:

List[str]

is_backend_available(backend)[source]

Check if a specific backend is available.

Parameters:

backend (str)

Return type:

bool

get_backend()[source]

Get the current backend, detecting automatically if not set.

Return type:

str

set_backend(backend)[source]

Set the backend to use.

Parameters:

backend (str) – Backend name (‘qt’ or ‘wx’)

Returns:

True if successfully set, False otherwise

Return type:

bool

get_backend_info()[source]

Get information about the current backend.

Return type:

Dict[str, Any]

vibegui.backend.get_backend()[source]

Get the current GUI backend.

Return type:

str

vibegui.backend.set_backend(backend)[source]

Set the GUI backend to use.

Parameters:

backend (str)

Return type:

bool

vibegui.backend.get_available_backends()[source]

Get list of available GUI backends.

Return type:

List[str]

vibegui.backend.get_backend_info()[source]

Get information about the current backend.

Return type:

Dict[str, Any]

vibegui.backend.is_backend_available(backend)[source]

Check if a specific backend is available.

Parameters:

backend (str)

Return type:

bool