Core Module
Main GuiBuilder Class
- class qtpyguihelper.GuiBuilder(config_path=None, config_dict=None, backend=None)[source]
Bases:
objectUnified 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().
- builder
The underlying backend-specific builder instance
Example
Basic usage with automatic backend detection:
>>> from qtpyguihelper import GuiBuilder >>> gui = GuiBuilder('config.json') >>> gui.show()
Force a specific backend:
>>> gui = GuiBuilder('config.json', backend='gtk') >>> gui.run()
Use with configuration dictionary:
>>> config = {"window": {"title": "My App"}, "fields": [...]} >>> gui = GuiBuilder(config_dict=config) >>> data = gui.get_form_data()
- 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
- Raises:
WidgetError – If the field doesn’t exist or can’t be accessed
- Return type:
- set_field_value(field_name, value)[source]
Set the value of a specific field.
- Parameters:
- Returns:
True if the value was set successfully, False otherwise
- Raises:
WidgetError – If the field doesn’t exist or value is invalid
- Return type:
- set_submit_callback(callback)[source]
Set a callback function to be called when the form is submitted.
- set_cancel_callback(callback)[source]
Set a callback function to be called when the form is cancelled.
- set_custom_button_callback(button_name, callback)[source]
Set a callback function to be called when a custom button is clicked.
- Parameters:
button_name (str)
- remove_custom_button_callback(button_name)[source]
Remove a custom button callback.
- Parameters:
button_name (str)
- save_data_to_file(data_file_path, include_empty=True)[source]
Save current form data to a JSON file.
Backend Management
Backend detection and selection for qtpyguihelper. Supports Qt (via qtpy), wxPython, tkinter, and GTK backends.
- class qtpyguihelper.backend.BackendManager[source]
Bases:
objectManages GUI backend selection and availability.
- SUPPORTED_BACKENDS = ['qt', 'wx', 'tk', 'gtk']
- DEFAULT_BACKEND = 'qt'