wxyz.html#

Widgets for core HTML 5 controls

class wxyz.html.AlphaColor(default_value=traitlets.Undefined, allow_none=False, read_only=None, help=None, config=None, **kwargs)[source]#

Bases: Color

A color with alpha

__get__(obj, cls=None)#

Get the value of the trait by self.name for the instance.

Default values are instantiated when HasTraits.__new__() is called. Thus by the time this method gets called either the default value or a user defined value (they called __set__()) is in the HasTraits instance.

__or__(other)#

Return self|value.

__set__(obj, value)#

Set the value of the trait by self.name for the instance.

Values pass through a validation stage where errors are raised when impropper types, or types that cannot be coerced, are encountered.

class_init(cls, name)#

Part of the initialization which may depend on the underlying HasDescriptors class.

It is typically overloaded for specific types.

This method is called by MetaHasDescriptors.__init__() passing the class (cls) and name under which the descriptor has been assigned.

default(obj=None)#

The default generator for this trait

Notes

This method is registered to HasTraits classes during class_init in the same way that dynamic defaults defined by @default are.

default_value: t.Optional[t.Any] = traitlets.Undefined#
error(obj, value, error=None, info=None)#

Raise a TraitError

Parameters:
  • obj (HasTraits or None) – The instance which owns the trait. If not object is given, then an object agnostic error will be raised.

  • value (any) – The value that caused the error.

  • error (Exception (default: None)) – An error that was raised by a child trait. The arguments of this exception should be of the form (value, info, *traits). Where the value and info are the problem value, and string describing the expected value. The traits are a series of TraitType instances that are “children” of this one (the first being the deepest).

  • info (str (default: None)) – A description of the expected value. By default this is infered from this trait’s info method.

from_string(s)#

Get a value from a config string

such as an environment variable or CLI arguments.

Traits can override this method to define their own parsing of config strings.

See also

item_from_string

New in version 5.0.

get_default_value()#

DEPRECATED: Retrieve the static default value for this trait. Use self.default_value instead

get_metadata(key, default=None)#

DEPRECATED: Get a metadata value.

Use .metadata[key] or .metadata.get(key, default) instead.

init_default_value(obj)#

DEPRECATED: Set the static default value for the trait type.

instance_init(obj)#

Part of the initialization which may depend on the underlying HasDescriptors instance.

It is typically overloaded for specific types.

This method is called by HasTraits.__new__() and in the BaseDescriptor.instance_init() method of descriptors holding other descriptors.

set_metadata(key, value)#

DEPRECATED: Set a metadata key/value.

Use .metadata[key] = value instead.

tag(**metadata)#

Sets metadata and returns self.

This allows convenient metadata tagging when initializing the trait, such as:

Examples

>>> Int(0).tag(config=True, sync=True)
<traitlets.traitlets.Int object at ...>
validate(obj, value)[source]#

expand the validation to work for rgba

class wxyz.html.AlphaColorPicker(**kwargs: Any)[source]#

Bases: ColorPicker

A color picker that should allow setting opacity

concise#

Display short version with just a color selector.

description#

Description of the control.

description_allow_html#

Accept HTML in the description.

property description_tooltip#

The tooltip information. .. deprecated :: 8.0.0

Use tooltip attribute instead.

disabled#

Enable or disable user changes.

get_interact_value()#

Return the value for this widget which should be passed to interactive functions. Custom widgets can change this method to process the raw value self.value.

style#

Styling customizations

class wxyz.html.EmptyAlphaColor(default_value=traitlets.Undefined, allow_none=False, read_only=None, help=None, config=None, **kwargs)[source]#

Bases: Color

A color with alpha that might be the empty string

__get__(obj, cls=None)#

Get the value of the trait by self.name for the instance.

Default values are instantiated when HasTraits.__new__() is called. Thus by the time this method gets called either the default value or a user defined value (they called __set__()) is in the HasTraits instance.

__or__(other)#

Return self|value.

__set__(obj, value)#

Set the value of the trait by self.name for the instance.

Values pass through a validation stage where errors are raised when impropper types, or types that cannot be coerced, are encountered.

class_init(cls, name)#

Part of the initialization which may depend on the underlying HasDescriptors class.

It is typically overloaded for specific types.

This method is called by MetaHasDescriptors.__init__() passing the class (cls) and name under which the descriptor has been assigned.

default(obj=None)#

The default generator for this trait

Notes

This method is registered to HasTraits classes during class_init in the same way that dynamic defaults defined by @default are.

default_value: t.Optional[t.Any] = traitlets.Undefined#
error(obj, value, error=None, info=None)#

Raise a TraitError

Parameters:
  • obj (HasTraits or None) – The instance which owns the trait. If not object is given, then an object agnostic error will be raised.

  • value (any) – The value that caused the error.

  • error (Exception (default: None)) – An error that was raised by a child trait. The arguments of this exception should be of the form (value, info, *traits). Where the value and info are the problem value, and string describing the expected value. The traits are a series of TraitType instances that are “children” of this one (the first being the deepest).

  • info (str (default: None)) – A description of the expected value. By default this is infered from this trait’s info method.

from_string(s)#

Get a value from a config string

such as an environment variable or CLI arguments.

Traits can override this method to define their own parsing of config strings.

See also

item_from_string

New in version 5.0.

get_default_value()#

DEPRECATED: Retrieve the static default value for this trait. Use self.default_value instead

get_metadata(key, default=None)#

DEPRECATED: Get a metadata value.

Use .metadata[key] or .metadata.get(key, default) instead.

init_default_value(obj)#

DEPRECATED: Set the static default value for the trait type.

instance_init(obj)#

Part of the initialization which may depend on the underlying HasDescriptors instance.

It is typically overloaded for specific types.

This method is called by HasTraits.__new__() and in the BaseDescriptor.instance_init() method of descriptors holding other descriptors.

set_metadata(key, value)#

DEPRECATED: Set a metadata key/value.

Use .metadata[key] = value instead.

tag(**metadata)#

Sets metadata and returns self.

This allows convenient metadata tagging when initializing the trait, such as:

Examples

>>> Int(0).tag(config=True, sync=True)
<traitlets.traitlets.Int object at ...>
validate(obj, value)[source]#

expand the validation to work for rgba

class wxyz.html.File(**kwargs: Any)[source]#

Bases: HTMLBase

A file. Might be uploaded from the browser.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file

last_modified#

Timestamp of last file modification

mime_type#

The file’s MIME type.

name#

The file’s name

proxy(klass, **kwargs)[source]#

Generate a Proxy file object, given a File-compatible class

size#

The size of the file in bytes

value#

The binary representation of the file

class wxyz.html.FileBox(**kwargs: Any)[source]#

Bases: HTMLBase, Box

A box of files, which can be used to upload and download files

accept#

uploadable extensions and mimetypes (with wildcards)

box_style#

Use a predefined styling for the box.

children#

List of file widgets

multiple#

if true, accept multiple files

class wxyz.html.Fullscreen(**kwargs: Any)[source]#

Bases: HTMLBase, Box

A full-screen Box, activated with Ctrl+Shift+Click, or the flower key on MacOS

box_style#

Use a predefined styling for the box.

children#

List of widget children

class wxyz.html.JSONFile(**kwargs: Any)[source]#

Bases: File

A JSON file

last_modified#

Timestamp of last file modification

mime_type#

The file’s MIME type.

name#

The file’s name

proxy(klass, **kwargs)#

Generate a Proxy file object, given a File-compatible class

size#

The size of the file in bytes

value#

The binary representation of the file

class wxyz.html.TextFile(**kwargs: Any)[source]#

Bases: File

A Text file

last_modified#

Timestamp of last file modification

mime_type#

The file’s MIME type.

name#

The file’s name

proxy(klass, **kwargs)#

Generate a Proxy file object, given a File-compatible class

size#

The size of the file in bytes

value#

The binary representation of the file