def control_autosend(): is_autosent = config.get("autosend", False) d = DialogBox("yn", i, o, message="Automatically send bugreports?", name="Autosend control dialog box") d.set_start_option(0 if is_autosent else 1) choice = d.activate() if choice is not None: config["autosend"] = True if choice else False save_config(config)
def test_start_option(self): db = DialogBox("ync", get_mock_input(), get_mock_output(), name=db_name) db.refresh = lambda *args, **kwargs: None db.set_start_option(1) #So, "No" option would be selected def scenario(): db.accept_value() # KEY_ENTER assert not db.in_foreground # Should exit with patch.object(db, 'idle_loop', side_effect=scenario) as p: return_value = db.activate() assert return_value is False #Second element - No, means False
def change_range(): global config dialogbox_options = [["Safe", "conservative"], ["Full", "full"], "c"] dialogbox = DialogBox(dialogbox_options, i, o, message="Scan range", name="I2C tools app range setting dialogbox") if config.get("scan_range", "conservative") == "full": # setting dialogbox position to the "full" option as it's currently selected dialogbox.set_start_option(1) new_range = dialogbox.activate() if new_range is not None: config["scan_range"] = new_range save_config(config)