input
Widgets for representing input widgets for different types.
The metaclass {class}`.Input` represents the basic structure, which each of the inheriting classes
override. Subclasses can be retrieved and instantiated with the overloaded from_type() method:
# retrieve the class
int_input_class = Input.from_type(int)
# instantiate the class -- some subtypes (see :class:`.LiteralInput` ) need arguments on instantiation.
int_input = int_input_class()
and can then be used to make and manipulate Qt Widgets:
# make the literal ``QWidget`` to be used
widget = int_input.make()
# get/set the value of the created widget
value = int_input.value()
int_input.setValue(value)
This allows the ModelWidget class to provide a uniform interface to fill end edit models.
Classes:
|
Metaclass to parametrically spawn a Qt Input widget for a given type. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class Input(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
abc.ABCMetaclass to parametrically spawn a Qt Input widget for a given type.
Primarily for the purpose of making a unified widget creation and value retreival syntax within the
ModelWidgetclass- widget: ClassVar[Type[PySide2.QtWidgets.QWidget]] = None
The widget that is made with the
make()method
- validator: ClassVar[Optional[Type[PySide2.QtGui.QValidator]]] = None
The validator applied to the input widget
- method_calls: ClassVar[Optional[List[Tuple[str, List]]]] = None
Names of methods to call after instantiation, passed as a tuple of (method_name, [method_args])
- python_type: ClassVar[Type]
The python type that this input provides interface for
- permissiveness: ClassVar[int] = 0
When a type is annotated with a Union, the more permissive (higher number) one will be chosen. Arbitrary units.
- args: Optional[list] = FieldInfo(default=PydanticUndefined, default_factory=<class 'list'>, extra={})
Args to pass to the widget on creation
- kwargs: Optional[dict] = FieldInfo(default=PydanticUndefined, default_factory=<class 'dict'>, extra={})
Kwargs to pass to the widget on creation
- range: Optional[Tuple[Union[int, float], Union[int, float]]] = None
Limit numerical types to a specific range
- classmethod from_type(type_: Type[bool]) Type[BoolInput][source]
- classmethod from_type(type_: Type[int]) Type[IntInput]
- classmethod from_type(type_: Type[float]) Type[FloatInput]
- classmethod from_type(type_: Type[str]) Type[StrInput]
- classmethod from_type(type_: Type[datetime.datetime]) Type[DatetimeInput]
- classmethod from_type(type_: Type[list]) Type[ListInput]
Get a subclass of
Inputthat represents a given type.- Parameters
type_ (
typing.Type) – The type (eg.float,int) to be represented- Returns
An appropriate
Inputsubclass- Raises
- abstract setValue(value: Any)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- abstract value() Any[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- make(widget_kwargs: Optional[dict] = None, validator_kwargs: Optional[dict] = None) PySide2.QtWidgets.QWidget[source]
Make the appropriate widget for this input.
Stores the made widget in the private
_widgetattr, which is then used in subsequentInput.value()andInput.setValue()calls.- Parameters
widget_kwargs (dict) – Optional: kwargs given to the widget on instantiation
validator_kwargs (dict) – Optional: kwargs given to the validator on instantiation
- Returns
Subclass of QWidget according to Input type
- Return type
PySide2.QtWidgets.QWidget
- class BoolInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QCheckBox
- setValue(value: bool)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() bool[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class IntInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QLineEdit
- validator
alias of
PySide2.QtGui.QIntValidator
- permissiveness: ClassVar[int] = 1
When a type is annotated with a Union, the more permissive (higher number) one will be chosen. Arbitrary units.
- setValue(value: int)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() Optional[int][source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class FloatInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QLineEdit
- validator
alias of
PySide2.QtGui.QIntValidator
- permissiveness: ClassVar[int] = (2,)
When a type is annotated with a Union, the more permissive (higher number) one will be chosen. Arbitrary units.
- setValue(value: float)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() Optional[float][source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class StrInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QLineEdit
- permissiveness: ClassVar[int] = 3
When a type is annotated with a Union, the more permissive (higher number) one will be chosen. Arbitrary units.
- setValue(value: str)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() str[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class DatetimeInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QDateTimeEdit
- method_calls: ClassVar[Optional[List[Tuple[str, List]]]] = [('setCalendarPopup', [True])]
Names of methods to call after instantiation, passed as a tuple of (method_name, [method_args])
- python_type
alias of
datetime.datetime
- setValue(value: datetime.datetime)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() datetime.datetime[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class ListInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QLineEdit
- setValue(value: list)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() list[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class DictInput(args: Optional[list] = None, kwargs: Optional[dict] = None, range: Optional[Tuple[Union[int, float], Union[int, float]]] = None)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QLineEdit
- setValue(value: dict)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() dict[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.
- class LiteralInput(choices: list, default: Optional[Any] = None, **kwargs)[source]
Bases:
autopilot.gui.widgets.input.Input- widget
alias of
PySide2.QtWidgets.QComboBox
- python_type(*args, **kwds): ClassVar[Type] = typing.Literal
The python type that this input provides interface for
- default: Optional[Any] = None
If one of the entries in the literal type should be default, set this on widget creation
- make(widget_kwargs: Optional[dict] = None, validator_kwargs: Optional[dict] = None) PySide2.QtWidgets.QComboBox[source]
Call the superclass make method, but then set the options for the combobox based on our
LiteralInput.argsattribute.- Parameters
widget_kwargs (dict) – Optional: kwargs given to the widget on instantiation
validator_kwargs (dict) – Optional: kwargs given to the validator on instantiation
- Returns
PySide2.QtWidgets.QComboBox
- setValue(value: Any)[source]
Set a value in the created widget
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then allows its value to be set, doing appropriate type conversions and invoking the correct methods.
- value() Any[source]
Retrieve the value from the widget!
After the
Input.make()method is called, returning a widget, the Input instance will store a reference to it. This method then returns the value, doing appropriate type conversion.