Fix imports, add Range step.

This commit is contained in:
David Bau
2022-03-17 19:50:19 -04:00
parent a0cad283de
commit bae48f28d1
2 changed files with 7 additions and 4 deletions
+5 -2
View File
@@ -43,6 +43,8 @@ DEALINGS IN THE SOFTWARE.
"""
import base64
import io
import json
import html
import re
@@ -621,12 +623,13 @@ class Textbox(Widget):
class Range(Widget):
def __init__(self, value=50, min=0, max=100, **kwargs):
def __init__(self, value=50, min=0, max=100, step=1, **kwargs):
super().__init__(**kwargs)
# databinding is defined using Property objects.
self.value = Property(value)
self.min = Property(min)
self.max = Property(max)
self.step = Property(step)
def widget_js(self):
# Note that the 'input' event would enable during-drag feedback,
@@ -644,7 +647,7 @@ class Range(Widget):
def widget_html(self):
return f'''<input {self.std_attrs()} type="range" value="{
self.value}" min="{self.min}" max="{self.max}">'''
self.value}" min="{self.min}" max="{self.max}" step="{self.step}">'''
class ColorPicker(Widget):
+2 -2
View File
@@ -1,8 +1,8 @@
from .labwidget import ImageWidget, Property
from .labwidget import Image, Property
import matplotlib, matplotlib.pyplot
import inspect
class PlotWidget(ImageWidget):
class PlotWidget(Image):
"""
A widget to create interactive matplotlib plots by defining a simple function.
Example of usage: