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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
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- method_calls: ClassVar[List[Tuple[str, List]] | None] = None
Names of methods to call after instantiation, passed as a tuple of (method_name, [method_args])
- permissiveness: ClassVar[int] = 0
When a type is annotated with a Union, the more permissive (higher number) one will be chosen. Arbitrary units.
- args: list | None = FieldInfo(default=PydanticUndefined, default_factory=<class 'list'>, extra={})
Args to pass to the widget on creation
- kwargs: dict | None = FieldInfo(default=PydanticUndefined, default_factory=<class 'dict'>, extra={})
Kwargs to pass to the widget on creation
- 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]) 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: dict | None = None, validator_kwargs: dict | None = None) 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:
PySide6.QtWidgets.QWidget
- class BoolInput(args: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
QLineEdit
- validator
alias of
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() int | None[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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
QLineEdit
- validator
alias of
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() float | None[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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
QDateTimeEdit
- method_calls: ClassVar[List[Tuple[str, List]] | None] = [('setCalendarPopup', [True])]
Names of methods to call after instantiation, passed as a tuple of (method_name, [method_args])
- setValue(value: 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[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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
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: list | None = None, kwargs: dict | None = None, range: Tuple[int | float, int | float] | None = None)[source]
Bases:
Input- widget
alias of
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: Any | None = None, **kwargs)[source]
Bases:
Input- widget
alias of
QComboBox
- python_type(*args, **kwds): ClassVar[Type] = typing.Literal
The python type that this input provides interface for
- default: Any | None = None
If one of the entries in the literal type should be default, set this on widget creation
- make(widget_kwargs: dict | None = None, validator_kwargs: dict | None = None) 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:
PySide6.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.