@@ -485,29 +485,26 @@ def result(self):
485485 def result (self , value ):
486486 self ._result = value
487487
488- class CheckBoxField :
488+ class CheckboxField :
489489 """
490- ``CheckBoxField `` prompts the user to choose a yes/no option in a checkbox.
490+ ``CheckboxField `` prompts the user to choose a yes/no option in a checkbox.
491491 Result is stored in self.result as a boolean value.
492492
493493 :param str prompt: Prompt to be presented to the user
494- :param Optional[bool]: Optional boolean value for the default setting of the checkbox. \
495- by default set to 'false'
496494 """
497495 def __init__ (self , prompt , default = None ):
498496 self ._prompt = prompt
499- self ._default = default
500497 self ._result = None
501498
502499 def _fill_core_struct (self , value ):
503- value .type = FormInputFieldType .CheckBoxFormField
500+ value .type = FormInputFieldType .CheckboxFormField
504501 value .prompt = self ._prompt
505- value .hasDefault = self ._default is not None
506- if self ._default is not None :
507- value .boolDefault = self ._default
508502
509503 def _fill_core_result (self , value ):
510- self ._boolResult = value .result
504+ value .intResult = self ._result
505+
506+ def _get_result (self , value ):
507+ self ._result = value .intResult
511508
512509 @property
513510 def prompt (self ):
@@ -525,14 +522,6 @@ def result(self):
525522 def result (self , value ):
526523 self ._result = value
527524
528- @property
529- def default (self ):
530- return self ._default
531-
532- @default .setter
533- def default (self , value ):
534- self ._default = value
535-
536525
537526class InteractionHandler :
538527 _interaction_handler = None
@@ -699,6 +688,16 @@ def _get_directory_name_input(self, ctxt, result, prompt, default_name):
699688 except :
700689 log_error (traceback .format_exc ())
701690
691+ def _get_checkbox_input (self , ctxt , result , prompt ):
692+ try :
693+ value = self .get_checkbox_input (prompt )
694+ if value is None :
695+ return False
696+ result [0 ] = value
697+ return True
698+ except :
699+ log_error (traceback .format_exc ())
700+
702701 def _get_form_input (self , ctxt , fields , count , title ):
703702 try :
704703 field_objs = []
@@ -763,10 +762,10 @@ def _get_form_input(self, ctxt, fields, count, title):
763762 default = fields [i ].stringDefault if fields [i ].hasDefault else None
764763 )
765764 )
766- elif fields [i ].type == FormInputFieldType .CheckBoxFormField :
765+ elif fields [i ].type == FormInputFieldType .CheckboxFormField :
767766 field_objs .append (
768- CheckBoxField (
769- fields [i ].prompt , default = fields [ i ]. boolDefault if fields [ i ]. hasDefault else None
767+ CheckboxField (
768+ fields [i ].prompt
770769 )
771770 )
772771 else :
@@ -850,6 +849,9 @@ def get_save_filename_input(self, prompt, ext, default_name):
850849 def get_directory_name_input (self , prompt , default_name ):
851850 return get_text_line_input (prompt , "Select Directory" )
852851
852+ def get_checkbox_input (self , prompt ):
853+ return get_checkbox_input (prompt , "Choose Option(s)" )
854+
853855 def get_form_input (self , fields , title ):
854856 return False
855857
@@ -1418,10 +1420,10 @@ def get_directory_name_input(prompt: str, default_name: str = ""):
14181420
14191421def get_checkbox_input (prompt : str , title : str ):
14201422 """
1421- ``get_checkbox_input`` prompts the user for a checkbox input, and returns True if the checkbox is checked, otherwise returns False.
1423+ ``get_checkbox_input`` prompts the user for a checkbox input
14221424 :param prompt: String to prompt with
14231425 :param title: Title of the window when executed in the UI
1424- :rtype: bool indicating the state of the checkbox
1426+ :rtype: int indicating the state of the checkbox
14251427 """
14261428 value = ctypes .c_bool ()
14271429 if not core .BNGetCheckboxInput (value , prompt , title ):
@@ -1450,6 +1452,7 @@ def get_form_input(fields, title):
14501452 OpenFileNameField Prompt for file to open
14511453 SaveFileNameField Prompt for file to save to
14521454 DirectoryNameField Prompt for directory name
1455+ CheckboxFormField Prompt for a checkbox
14531456 ===================== ===================================================
14541457
14551458 This API is flexible and works both in the UI via a pop-up dialog and on the command-line.
0 commit comments