dlg_comp_callback()

Sets a callback function for a dialog component, allowing for event-driven behavior (e.g., when a button is clicked).

Note that callback functions are not supported if the dialog is running in a waiting state.

Syntax

planetcnc.dlg_comp_callback(component, callback, callbackArg=None)

Parameters

Parameter Type Description Comment
component capsule Capsule object representing the component.
callback function Function to call when the component is activated. Must be callable.
callbackArg int Optional argument passed to the callback function. optional

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
def my_callback(*args):
    print("Component callback invoked!", args)
 
# Assign a callback to a button component
planetcnc.dlg_comp_callback(my_button_component, my_callback)
 
# Assign a callback with an optional argument
planetcnc.dlg_comp_callback(my_button_component, my_callback, 42)

See also

dlg_comp_pos
dlg_comp_size
dlg_comp_color
dlg_comp_font
dlg_comp_name
dlg_comp_value
dlg_comp_callback