Skip to content

Instantly share code, notes, and snippets.

@bjonnh
Created January 30, 2018 17:04
Show Gist options
  • Save bjonnh/2ee3fe9a263f382593c06078feaeb2e9 to your computer and use it in GitHub Desktop.
Save bjonnh/2ee3fe9a263f382593c06078feaeb2e9 to your computer and use it in GitHub Desktop.
from beakerx import EasyForm, EasyFormComponent, BeakerxLayout, widget_serialization, getValue
from beakerx import BeakerxText
from ipywidgets.widgets.trait_types import InstanceDict
from beakerx import Int, Unicode, Dict, Bool, Union, List
from ipywidgets import Password, Text
class BeakerxPassword(Password, EasyFormComponent):
def on_value_change(self, change):
self.fireChanged(change['new'])
def __init__(self, **kwargs):
super(BeakerxPassword, self).__init__(**kwargs)
self.observe(self.on_value_change, names='value')
_view_module = Unicode('beakerx').tag(sync=True)
_model_module = Unicode('beakerx').tag(sync=True)
_model_module_version = Unicode('*').tag(sync=True)
_view_module_version = Unicode('*').tag(sync=True)
size = Int(default_value=-1).tag(sync=True)
layout = InstanceDict(BeakerxLayout).tag(sync=True, **widget_serialization)
style = None
class EasyFormWPass(EasyForm):
def addPasswordField(self, *args, **kwargs):
text = BeakerxPassword(description=self.getDescription(args, kwargs))
text.size = getValue(kwargs, 'width', -1)
self.children += (text,)
self.components[text.description] = text
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment