MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / simple_option

Method simple_option

src/ptpython/python_input.py:571–593  ·  view source on GitHub ↗

Create Simple on/of option.

(
            title: str,
            description: str,
            field_name: str,
            values: tuple[str, str] = ("off", "on"),
        )

Source from the content-addressed store, hash-verified

569 return True
570
571 def simple_option(
572 title: str,
573 description: str,
574 field_name: str,
575 values: tuple[str, str] = ("off", "on"),
576 ) -> Option[str]:
577 "Create Simple on/of option."
578
579 def get_current_value() -> str:
580 return values[bool(getattr(self, field_name))]
581
582 def get_values() -> dict[str, Callable[[], bool]]:
583 return {
584 values[1]: lambda: enable(field_name),
585 values[0]: lambda: disable(field_name),
586 }
587
588 return Option(
589 title=title,
590 description=description,
591 get_values=get_values,
592 get_current_value=get_current_value,
593 )
594
595 brightness_values = [1.0 / 20 * value for value in range(0, 21)]
596

Callers

nothing calls this directly

Calls 1

OptionClass · 0.85

Tested by

no test coverage detected