dlg_add_option()

Adds an item to the “Options” menu in a dialog window.

A callback function can optionally be specified, which will be triggered when the menu item is selected.

Syntax

planetcnc.dlg_add_option(handle, name, callback=None, callbackArg=None)

Parameters

Parameter Type Description Comment
handle string Handle of the dialog where the menu item will be added.
name string Text label for the new menu item.
callback function An optional function to execute when the menu item is selected. optional
callbackArg int An optional integer argument passed to the callback. optional

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
def on_option_selected(*args):
    print("Option selected with args:", args)
 
dlg_handle = planetcnc.dlg_new("Examples")
 
planetcnc.dlg_add_option(dlg_handle, "First", on_option_selected, 11)
planetcnc.dlg_add_option(dlg_handle, "Second", on_option_selected, 22)
planetcnc.dlg_add_option(dlg_handle, "Third", on_option_selected, 33)
 
planetcnc.dlg_add_label(dlg_handle, "", "Hello, World!")
 
planetcnc.dlg_show(dlg_handle)

See also

dlg_add_option
dlg_add_image
dlg_add_label
dlg_add_checkbox
dlg_add_num_input
dlg_add_txt_input
dlg_add_dropbox
dlg_add_button