dlg_add_button()

Adds a button component to a dialog.

The button can have a name and label text.

Syntax

planetcnc.dlg_add_button(handle, name=None, text=None, callback=None, id=None)

Parameters

Parameter Type Description Comment
handle string Handle of the dialog to modify.
name string Name identifier for the button. optional
text string Label text displayed on the button. optional

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
# Define a callback function
def on_button_click(comp, id):
    print("Button clicked!")
 
dlg_handle = planetcnc.dlg_new("Examples")
 
# Add a buttons to a dialog
comp = planetcnc.dlg_add_button(dlg_handle , "", "Click 1")
planetcnc.dlg_comp_callback(comp, on_button_click, 1)
 
comp = planetcnc.dlg_add_button(dlg_handle , "", "Click 2")
planetcnc.dlg_comp_callback(comp, on_button_click, 2)
 
comp = planetcnc.dlg_add_button(dlg_handle , "", "Click 3")
planetcnc.dlg_comp_callback(comp, on_button_click, 3)
 
planetcnc.dlg_show(dlg_handle)

See also

dlg_add_option
dlg_add_separator
dlg_add_image
dlg_add_label
dlg_add_checkbox
dlg_add_num_input
dlg_add_txt_input
dlg_add_dropbox
dlg_add_button