We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Adding size attribute to MultiSelect model
Small feature request: it would be nice to have an attribute to toggle number of visible elements in MultiSelect. Note that this can't exactly be controlled by CSS (the height property can be used, but I'm not sure if there's an easy way to set it to exactly match the height of the options). Since the options can be dynamically set, it seems reasonable to me to also let the size attribute be dynamically set.

This is implemented in these commits: [commit1](https://github.com/azjps/bokeh/commit/504910486751c5e947edd9217f186ede87f82b48), [commit2 which is an unrelated typo fix](https://github.com/azjps/bokeh/commit/0ff1290210af58b59cbecbcd84e98dc6d1248349) I haven't submitted a PR yet, noticed that PR etiquette dictates to submit an issue first.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bokeh/models/widgets/inputs.py`
Content:
```
1 """ Various kinds of input widgets and form controls.
2 
3 """
4 from __future__ import absolute_import
5 
6 from ...core.properties import abstract
7 from ...core.properties import Bool, Int, Float, String, Date, RelativeDelta, Enum, List, Tuple, Either, Instance
8 from ..callbacks import Callback
9 from .widget import Widget
10 from ...core.enums import SliderCallbackPolicy
11 
12 @abstract
13 class InputWidget(Widget):
14     """ Abstract base class for input widgets. `InputWidget`` is not
15     generally useful to instantiate on its own.
16 
17     """
18 
19     title = String(default="", help="""
20     Widget's label.
21     """)
22 
23     @classmethod
24     def coerce_value(cls, val):
25         prop_obj = cls.lookup('value')
26         if isinstance(prop_obj, Float):
27             return float(val)
28         elif isinstance(prop_obj, Int):
29             return int(val)
30         elif isinstance(prop_obj, String):
31             return str(val)
32         else:
33             return val
34 
35 class TextInput(InputWidget):
36     """ Single-line input widget. """
37 
38     value = String(default="", help="""
39     Initial or entered text value.
40     """)
41 
42     callback = Instance(Callback, help="""
43     A callback to run in the browser whenever the user unfocuses the TextInput
44     widget by hitting Enter or clicking outside of the text box area.
45     """)
46 
47     placeholder = String(default="", help="""
48     Placeholder for empty input field
49     """)
50 
51 
52 class AutocompleteInput(TextInput):
53     """ Single-line input widget with auto-completion. """
54 
55     completions = List(String, help="""
56     A list of completion strings. This will be used to guide the
57     user upon typing the beginning of a desired value.
58     """)
59 
60 
61 class Select(InputWidget):
62     """ Single-select widget.
63 
64     """
65 
66     options = List(Either(String, Tuple(String, String)), help="""
67     Available selection options. Options may be provided either as a list of
68     possible string values, or as a list of tuples, each of the form
69     ``(value, label)``. In the latter case, the visible widget text for each
70     value will be corresponding given label.
71     """)
72 
73     value = String(default="", help="""
74     Initial or selected value.
75     """)
76 
77     callback = Instance(Callback, help="""
78     A callback to run in the browser whenever the current Select dropdown
79     value changes.
80     """)
81 
82 class MultiSelect(InputWidget):
83     """ Multi-select widget.
84 
85     """
86 
87     options = List(Either(String, Tuple(String, String)), help="""
88     Available selection options. Options may be provided either as a list of
89     possible string values, or as a list of tuples, each of the form
90     ``(value, label)``. In the latter case, the visible widget text for each
91     value will be corresponding given label.
92     """)
93 
94     value = List(String, help="""
95     Initial or selected values.
96     """)
97 
98     callback = Instance(Callback, help="""
99     A callback to run in the browser whenever the current dropdown value
100     changes.
101     """)
102 
103 class Slider(InputWidget):
104     """ Slider-based number selection widget.
105 
106     """
107 
108     value = Float(default=0.5, help="""
109     Initial or selected value.
110     """)
111 
112     start = Float(default=0, help="""
113     The minimum allowable value.
114     """)
115 
116     end = Float(default=1, help="""
117     The maximum allowable value.
118     """)
119 
120     step = Float(default=0.1, help="""
121     The step between consecutive values.
122     """)
123 
124     orientation = Enum("horizontal", "vertical", help="""
125     Orient the slider either horizontally (default) or vertically.
126     """)
127 
128     callback = Instance(Callback, help="""
129     A callback to run in the browser whenever the current Slider value changes.
130     """)
131 
132     callback_throttle = Float(default=200, help="""
133     Number of microseconds to pause between callback calls as the slider is moved.
134     """)
135 
136     callback_policy = Enum(SliderCallbackPolicy, default="throttle", help="""
137     When the callback is initiated. This parameter can take on only one of three options:
138 
139        "continuous": the callback will be executed immediately for each movement of the slider
140        "throttle": the callback will be executed at most every ``callback_throttle`` milliseconds.
141        "mouseup": the callback will be executed only once when the slider is released.
142 
143        The `mouseup` policy is intended for scenarios in which the callback is expensive in time.
144     """)
145 
146 class RangeSlider(InputWidget):
147     """ Range-slider based range selection widget
148 
149     """
150 
151     range = Tuple(Float, Float, default=(0.1, 0.9), help="""
152     Initial or selected range.
153     """)
154 
155     start = Float(default=0, help="""
156     The minimum allowable value.
157     """)
158 
159     end = Float(default=1, help="""
160     The maximum allowable value.
161     """)
162 
163     step = Float(default=0.1, help="""
164     The step between consecutive values.
165     """)
166 
167     orientation = Enum("horizontal", "vertical", help="""
168     Orient the slider either horizontally (default) or vertically.
169     """)
170 
171     callback = Instance(Callback, help="""
172     A callback to run in the browser whenever the current Slider value changes.
173     """)
174 
175     callback_throttle = Float(default=200, help="""
176     Number of microseconds to pause between callback calls as the slider is moved.
177     """)
178 
179     callback_policy = Enum(SliderCallbackPolicy, default="throttle", help="""
180     When the callback is initiated. This parameter can take on only one of three options:
181 
182        "continuous": the callback will be executed immediately for each movement of the slider
183        "throttle": the callback will be executed at most every ``callback_throttle`` milliseconds.
184        "mouseup": the callback will be executed only once when the slider is released.
185 
186        The `mouseup` policy is intended for scenarios in which the callback is expensive in time.
187     """)
188 
189 
190 class DateRangeSlider(InputWidget):
191     """ Slider-based date range selection widget.
192 
193     """
194 
195     value = Tuple(Date, Date, help="""
196     The initial or selected date range.
197     """)
198 
199     bounds = Tuple(Date, Date, help="""
200     The earliest and latest allowable dates.
201     """)
202 
203     range = Tuple(RelativeDelta, RelativeDelta, help="""
204     [TDB]
205     """)
206 
207     step = RelativeDelta(help="""
208     The step between consecutive dates.
209     """)
210 
211     # formatter = Either(String, Function(Date))
212     # scales = DateRangeSliderScales ... # first, next, stop, label, format
213 
214     enabled = Bool(True, help="""
215     Enable or disable this widget.
216     """)
217 
218     arrows = Bool(True, help="""
219     Whether to show clickable arrows on both ends of the slider.
220     """)
221 
222     value_labels = Enum("show", "hide", "change", help="""
223     Show or hide value labels on both sides of the slider.
224     """)
225 
226     wheel_mode = Enum("scroll", "zoom", default=None, help="""
227     Whether mouse zoom should scroll or zoom selected range (or
228     do nothing).
229     """)
230 
231     callback = Instance(Callback, help="""
232     A callback to run in the browser whenever either slider's value changes.
233     """)
234 
235 class DatePicker(InputWidget):
236     """ Calendar-based date picker widget.
237 
238     """
239 
240     value = Date(help="""
241     The initial or picked date.
242     """)
243 
244     min_date = Date(default=None, help="""
245     Optional earliest allowable date.
246     """)
247 
248     max_date = Date(default=None, help="""
249     Optional latest allowable date.
250     """)
251 
252     callback = Instance(Callback, help="""
253     A callback to run in the browser whenever the current date value changes.
254     """)
255
```

Path: `examples/models/widgets.py`
Content:
```
1 from __future__ import print_function
2 
3 from datetime import date
4 
5 from bokeh.document import Document
6 from bokeh.embed import file_html
7 from bokeh.resources import INLINE
8 from bokeh.util.browser import view
9 from bokeh.models.layouts import Column, Row, WidgetBox
10 from bokeh.models.widgets import (
11     Button, Toggle, Dropdown,
12     CheckboxGroup, RadioGroup,
13     CheckboxButtonGroup, RadioButtonGroup,
14     TextInput, AutocompleteInput,
15     Select, MultiSelect,
16     Slider, RangeSlider, DateRangeSlider,
17     DatePicker,
18     Paragraph, Div, PreText,
19     Panel, Tabs,
20 )
21 from bokeh.plotting import figure
22 from bokeh.sampledata.iris import flowers
23 
24 button = Button(label="Button (disabled) - still has click event", button_type="primary", disabled=True)
25 
26 toggle = Toggle(label="Toggle button", button_type="success")
27 
28 menu = [("Item 1", "item_1_value"), ("Item 2", "item_2_value"), ("Item 3", "item_3_value")]
29 dropdown = Dropdown(label="Dropdown button", button_type="warning", menu=menu, default_value="item_1_value")
30 
31 split_menu = [("Item 1", "item_1_value"), ("Item 2", "item_2_value"), None, ("Item 3", "item_3_value")]
32 split = Dropdown(label="Split button", button_type="danger", menu=split_menu)
33 
34 checkbox_group = CheckboxGroup(labels=["Option 1", "Option 2", "Option 3"], active=[0, 1])
35 
36 radio_group = RadioGroup(labels=["Option 1", "Option 2", "Option 3"], active=0)
37 
38 checkbox_button_group = CheckboxButtonGroup(labels=["Option 1", "Option 2", "Option 3"], active=[0, 1])
39 
40 radio_button_group = RadioButtonGroup(labels=["Option 1", "Option 2", "Option 3"], active=0)
41 
42 text_input = TextInput(placeholder="Enter value ...")
43 
44 autocomplete_input = AutocompleteInput()
45 
46 select = Select(options=["Option 1", "Option 2", "Option 3"])
47 
48 multi_select = MultiSelect(options=["Option 1", "Option 2", "Option 3"])
49 
50 slider = Slider(value=10, start=0, end=100)
51 
52 range_slider = RangeSlider()
53 
54 #date_range_slider = DateRangeSlider(value=(date(2016, 1, 1), date(2016, 12, 31)))
55 
56 date_picker = DatePicker()
57 
58 paragraph = Paragraph(text="some text")
59 
60 div = Div(text="some <b>text</b>")
61 
62 pre_text = PreText(text="some text")
63 
64 def mk_tab(color):
65     plot = figure(width=300, height=300)
66     plot.scatter(flowers["petal_length"], flowers["petal_width"], color=color, fill_alpha=0.2, size=12)
67     return Panel(title="Tab 1: %s" % color.capitalize(), child=plot)
68 
69 tabs = Tabs(tabs=[mk_tab("red"), mk_tab("green"), mk_tab("blue")])
70 
71 widgets = Row(children=[
72     WidgetBox(children=[
73         button, toggle, dropdown, split,
74         checkbox_group, radio_group,
75         checkbox_button_group, radio_button_group,
76     ]),
77     WidgetBox(children=[
78         text_input, autocomplete_input,
79         select, multi_select,
80         slider, range_slider, #date_range_slider,
81         date_picker,
82         paragraph, div, pre_text,
83     ]),
84     WidgetBox(children=[
85         tabs,
86     ], width=400),
87 ])
88 
89 doc = Document()
90 doc.add_root(widgets)
91 
92 if __name__ == "__main__":
93     doc.validate()
94     filename = "widgets.html"
95     with open(filename, "w") as f:
96         f.write(file_html(doc, INLINE, "Widgets"))
97     print("Wrote %s" % filename)
98     view(filename)
99
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/bokeh/models/widgets/inputs.py b/bokeh/models/widgets/inputs.py
--- a/bokeh/models/widgets/inputs.py
+++ b/bokeh/models/widgets/inputs.py
@@ -96,10 +96,16 @@
     """)
 
     callback = Instance(Callback, help="""
-    A callback to run in the browser whenever the current dropdown value
+    A callback to run in the browser whenever the current selection value
     changes.
     """)
 
+    size = Int(default=4, help="""
+    The number of visible options in the dropdown list. (This uses the
+    ``select`` HTML element's ``size`` attribute. Some browsers might not
+    show less than 3 options.)
+    """)
+
 class Slider(InputWidget):
     """ Slider-based number selection widget.
 
diff --git a/examples/models/widgets.py b/examples/models/widgets.py
--- a/examples/models/widgets.py
+++ b/examples/models/widgets.py
@@ -45,7 +45,7 @@
 
 select = Select(options=["Option 1", "Option 2", "Option 3"])
 
-multi_select = MultiSelect(options=["Option 1", "Option 2", "Option 3"])
+multi_select = MultiSelect(options=["Option %d" % (i+1) for i in range(16)], size=6)
 
 slider = Slider(value=10, start=0, end=100)

{"golden_diff": "diff --git a/bokeh/models/widgets/inputs.py b/bokeh/models/widgets/inputs.py\n--- a/bokeh/models/widgets/inputs.py\n+++ b/bokeh/models/widgets/inputs.py\n@@ -96,10 +96,16 @@\n     \"\"\")\n \n     callback = Instance(Callback, help=\"\"\"\n-    A callback to run in the browser whenever the current dropdown value\n+    A callback to run in the browser whenever the current selection value\n     changes.\n     \"\"\")\n \n+    size = Int(default=4, help=\"\"\"\n+    The number of visible options in the dropdown list. (This uses the\n+    ``select`` HTML element's ``size`` attribute. Some browsers might not\n+    show less than 3 options.)\n+    \"\"\")\n+\n class Slider(InputWidget):\n     \"\"\" Slider-based number selection widget.\n \ndiff --git a/examples/models/widgets.py b/examples/models/widgets.py\n--- a/examples/models/widgets.py\n+++ b/examples/models/widgets.py\n@@ -45,7 +45,7 @@\n \n select = Select(options=[\"Option 1\", \"Option 2\", \"Option 3\"])\n \n-multi_select = MultiSelect(options=[\"Option 1\", \"Option 2\", \"Option 3\"])\n+multi_select = MultiSelect(options=[\"Option %d\" % (i+1) for i in range(16)], size=6)\n \n slider = Slider(value=10, start=0, end=100)\n", "issue": "Adding size attribute to MultiSelect model\nSmall feature request: it would be nice to have an attribute to toggle number of visible elements in MultiSelect. Note that this can't exactly be controlled by CSS (the height property can be used, but I'm not sure if there's an easy way to set it to exactly match the height of the options). Since the options can be dynamically set, it seems reasonable to me to also let the size attribute be dynamically set.\r\n\r\nThis is implemented in these commits: [commit1](https://github.com/azjps/bokeh/commit/504910486751c5e947edd9217f186ede87f82b48), [commit2 which is an unrelated typo fix](https://github.com/azjps/bokeh/commit/0ff1290210af58b59cbecbcd84e98dc6d1248349) I haven't submitted a PR yet, noticed that PR etiquette dictates to submit an issue first.\n", "before_files": [{"content": "\"\"\" Various kinds of input widgets and form controls.\n\n\"\"\"\nfrom __future__ import absolute_import\n\nfrom ...core.properties import abstract\nfrom ...core.properties import Bool, Int, Float, String, Date, RelativeDelta, Enum, List, Tuple, Either, Instance\nfrom ..callbacks import Callback\nfrom .widget import Widget\nfrom ...core.enums import SliderCallbackPolicy\n\n@abstract\nclass InputWidget(Widget):\n    \"\"\" Abstract base class for input widgets. `InputWidget`` is not\n    generally useful to instantiate on its own.\n\n    \"\"\"\n\n    title = String(default=\"\", help=\"\"\"\n    Widget's label.\n    \"\"\")\n\n    @classmethod\n    def coerce_value(cls, val):\n        prop_obj = cls.lookup('value')\n        if isinstance(prop_obj, Float):\n            return float(val)\n        elif isinstance(prop_obj, Int):\n            return int(val)\n        elif isinstance(prop_obj, String):\n            return str(val)\n        else:\n            return val\n\nclass TextInput(InputWidget):\n    \"\"\" Single-line input widget. \"\"\"\n\n    value = String(default=\"\", help=\"\"\"\n    Initial or entered text value.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the user unfocuses the TextInput\n    widget by hitting Enter or clicking outside of the text box area.\n    \"\"\")\n\n    placeholder = String(default=\"\", help=\"\"\"\n    Placeholder for empty input field\n    \"\"\")\n\n\nclass AutocompleteInput(TextInput):\n    \"\"\" Single-line input widget with auto-completion. \"\"\"\n\n    completions = List(String, help=\"\"\"\n    A list of completion strings. This will be used to guide the\n    user upon typing the beginning of a desired value.\n    \"\"\")\n\n\nclass Select(InputWidget):\n    \"\"\" Single-select widget.\n\n    \"\"\"\n\n    options = List(Either(String, Tuple(String, String)), help=\"\"\"\n    Available selection options. Options may be provided either as a list of\n    possible string values, or as a list of tuples, each of the form\n    ``(value, label)``. In the latter case, the visible widget text for each\n    value will be corresponding given label.\n    \"\"\")\n\n    value = String(default=\"\", help=\"\"\"\n    Initial or selected value.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Select dropdown\n    value changes.\n    \"\"\")\n\nclass MultiSelect(InputWidget):\n    \"\"\" Multi-select widget.\n\n    \"\"\"\n\n    options = List(Either(String, Tuple(String, String)), help=\"\"\"\n    Available selection options. Options may be provided either as a list of\n    possible string values, or as a list of tuples, each of the form\n    ``(value, label)``. In the latter case, the visible widget text for each\n    value will be corresponding given label.\n    \"\"\")\n\n    value = List(String, help=\"\"\"\n    Initial or selected values.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current dropdown value\n    changes.\n    \"\"\")\n\nclass Slider(InputWidget):\n    \"\"\" Slider-based number selection widget.\n\n    \"\"\"\n\n    value = Float(default=0.5, help=\"\"\"\n    Initial or selected value.\n    \"\"\")\n\n    start = Float(default=0, help=\"\"\"\n    The minimum allowable value.\n    \"\"\")\n\n    end = Float(default=1, help=\"\"\"\n    The maximum allowable value.\n    \"\"\")\n\n    step = Float(default=0.1, help=\"\"\"\n    The step between consecutive values.\n    \"\"\")\n\n    orientation = Enum(\"horizontal\", \"vertical\", help=\"\"\"\n    Orient the slider either horizontally (default) or vertically.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Slider value changes.\n    \"\"\")\n\n    callback_throttle = Float(default=200, help=\"\"\"\n    Number of microseconds to pause between callback calls as the slider is moved.\n    \"\"\")\n\n    callback_policy = Enum(SliderCallbackPolicy, default=\"throttle\", help=\"\"\"\n    When the callback is initiated. This parameter can take on only one of three options:\n\n       \"continuous\": the callback will be executed immediately for each movement of the slider\n       \"throttle\": the callback will be executed at most every ``callback_throttle`` milliseconds.\n       \"mouseup\": the callback will be executed only once when the slider is released.\n\n       The `mouseup` policy is intended for scenarios in which the callback is expensive in time.\n    \"\"\")\n\nclass RangeSlider(InputWidget):\n    \"\"\" Range-slider based range selection widget\n\n    \"\"\"\n\n    range = Tuple(Float, Float, default=(0.1, 0.9), help=\"\"\"\n    Initial or selected range.\n    \"\"\")\n\n    start = Float(default=0, help=\"\"\"\n    The minimum allowable value.\n    \"\"\")\n\n    end = Float(default=1, help=\"\"\"\n    The maximum allowable value.\n    \"\"\")\n\n    step = Float(default=0.1, help=\"\"\"\n    The step between consecutive values.\n    \"\"\")\n\n    orientation = Enum(\"horizontal\", \"vertical\", help=\"\"\"\n    Orient the slider either horizontally (default) or vertically.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Slider value changes.\n    \"\"\")\n\n    callback_throttle = Float(default=200, help=\"\"\"\n    Number of microseconds to pause between callback calls as the slider is moved.\n    \"\"\")\n\n    callback_policy = Enum(SliderCallbackPolicy, default=\"throttle\", help=\"\"\"\n    When the callback is initiated. This parameter can take on only one of three options:\n\n       \"continuous\": the callback will be executed immediately for each movement of the slider\n       \"throttle\": the callback will be executed at most every ``callback_throttle`` milliseconds.\n       \"mouseup\": the callback will be executed only once when the slider is released.\n\n       The `mouseup` policy is intended for scenarios in which the callback is expensive in time.\n    \"\"\")\n\n\nclass DateRangeSlider(InputWidget):\n    \"\"\" Slider-based date range selection widget.\n\n    \"\"\"\n\n    value = Tuple(Date, Date, help=\"\"\"\n    The initial or selected date range.\n    \"\"\")\n\n    bounds = Tuple(Date, Date, help=\"\"\"\n    The earliest and latest allowable dates.\n    \"\"\")\n\n    range = Tuple(RelativeDelta, RelativeDelta, help=\"\"\"\n    [TDB]\n    \"\"\")\n\n    step = RelativeDelta(help=\"\"\"\n    The step between consecutive dates.\n    \"\"\")\n\n    # formatter = Either(String, Function(Date))\n    # scales = DateRangeSliderScales ... # first, next, stop, label, format\n\n    enabled = Bool(True, help=\"\"\"\n    Enable or disable this widget.\n    \"\"\")\n\n    arrows = Bool(True, help=\"\"\"\n    Whether to show clickable arrows on both ends of the slider.\n    \"\"\")\n\n    value_labels = Enum(\"show\", \"hide\", \"change\", help=\"\"\"\n    Show or hide value labels on both sides of the slider.\n    \"\"\")\n\n    wheel_mode = Enum(\"scroll\", \"zoom\", default=None, help=\"\"\"\n    Whether mouse zoom should scroll or zoom selected range (or\n    do nothing).\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever either slider's value changes.\n    \"\"\")\n\nclass DatePicker(InputWidget):\n    \"\"\" Calendar-based date picker widget.\n\n    \"\"\"\n\n    value = Date(help=\"\"\"\n    The initial or picked date.\n    \"\"\")\n\n    min_date = Date(default=None, help=\"\"\"\n    Optional earliest allowable date.\n    \"\"\")\n\n    max_date = Date(default=None, help=\"\"\"\n    Optional latest allowable date.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current date value changes.\n    \"\"\")\n", "path": "bokeh/models/widgets/inputs.py"}, {"content": "from __future__ import print_function\n\nfrom datetime import date\n\nfrom bokeh.document import Document\nfrom bokeh.embed import file_html\nfrom bokeh.resources import INLINE\nfrom bokeh.util.browser import view\nfrom bokeh.models.layouts import Column, Row, WidgetBox\nfrom bokeh.models.widgets import (\n    Button, Toggle, Dropdown,\n    CheckboxGroup, RadioGroup,\n    CheckboxButtonGroup, RadioButtonGroup,\n    TextInput, AutocompleteInput,\n    Select, MultiSelect,\n    Slider, RangeSlider, DateRangeSlider,\n    DatePicker,\n    Paragraph, Div, PreText,\n    Panel, Tabs,\n)\nfrom bokeh.plotting import figure\nfrom bokeh.sampledata.iris import flowers\n\nbutton = Button(label=\"Button (disabled) - still has click event\", button_type=\"primary\", disabled=True)\n\ntoggle = Toggle(label=\"Toggle button\", button_type=\"success\")\n\nmenu = [(\"Item 1\", \"item_1_value\"), (\"Item 2\", \"item_2_value\"), (\"Item 3\", \"item_3_value\")]\ndropdown = Dropdown(label=\"Dropdown button\", button_type=\"warning\", menu=menu, default_value=\"item_1_value\")\n\nsplit_menu = [(\"Item 1\", \"item_1_value\"), (\"Item 2\", \"item_2_value\"), None, (\"Item 3\", \"item_3_value\")]\nsplit = Dropdown(label=\"Split button\", button_type=\"danger\", menu=split_menu)\n\ncheckbox_group = CheckboxGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=[0, 1])\n\nradio_group = RadioGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=0)\n\ncheckbox_button_group = CheckboxButtonGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=[0, 1])\n\nradio_button_group = RadioButtonGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=0)\n\ntext_input = TextInput(placeholder=\"Enter value ...\")\n\nautocomplete_input = AutocompleteInput()\n\nselect = Select(options=[\"Option 1\", \"Option 2\", \"Option 3\"])\n\nmulti_select = MultiSelect(options=[\"Option 1\", \"Option 2\", \"Option 3\"])\n\nslider = Slider(value=10, start=0, end=100)\n\nrange_slider = RangeSlider()\n\n#date_range_slider = DateRangeSlider(value=(date(2016, 1, 1), date(2016, 12, 31)))\n\ndate_picker = DatePicker()\n\nparagraph = Paragraph(text=\"some text\")\n\ndiv = Div(text=\"some <b>text</b>\")\n\npre_text = PreText(text=\"some text\")\n\ndef mk_tab(color):\n    plot = figure(width=300, height=300)\n    plot.scatter(flowers[\"petal_length\"], flowers[\"petal_width\"], color=color, fill_alpha=0.2, size=12)\n    return Panel(title=\"Tab 1: %s\" % color.capitalize(), child=plot)\n\ntabs = Tabs(tabs=[mk_tab(\"red\"), mk_tab(\"green\"), mk_tab(\"blue\")])\n\nwidgets = Row(children=[\n    WidgetBox(children=[\n        button, toggle, dropdown, split,\n        checkbox_group, radio_group,\n        checkbox_button_group, radio_button_group,\n    ]),\n    WidgetBox(children=[\n        text_input, autocomplete_input,\n        select, multi_select,\n        slider, range_slider, #date_range_slider,\n        date_picker,\n        paragraph, div, pre_text,\n    ]),\n    WidgetBox(children=[\n        tabs,\n    ], width=400),\n])\n\ndoc = Document()\ndoc.add_root(widgets)\n\nif __name__ == \"__main__\":\n    doc.validate()\n    filename = \"widgets.html\"\n    with open(filename, \"w\") as f:\n        f.write(file_html(doc, INLINE, \"Widgets\"))\n    print(\"Wrote %s\" % filename)\n    view(filename)\n", "path": "examples/models/widgets.py"}], "after_files": [{"content": "\"\"\" Various kinds of input widgets and form controls.\n\n\"\"\"\nfrom __future__ import absolute_import\n\nfrom ...core.properties import abstract\nfrom ...core.properties import Bool, Int, Float, String, Date, RelativeDelta, Enum, List, Tuple, Either, Instance\nfrom ..callbacks import Callback\nfrom .widget import Widget\nfrom ...core.enums import SliderCallbackPolicy\n\n@abstract\nclass InputWidget(Widget):\n    \"\"\" Abstract base class for input widgets. `InputWidget`` is not\n    generally useful to instantiate on its own.\n\n    \"\"\"\n\n    title = String(default=\"\", help=\"\"\"\n    Widget's label.\n    \"\"\")\n\n    @classmethod\n    def coerce_value(cls, val):\n        prop_obj = cls.lookup('value')\n        if isinstance(prop_obj, Float):\n            return float(val)\n        elif isinstance(prop_obj, Int):\n            return int(val)\n        elif isinstance(prop_obj, String):\n            return str(val)\n        else:\n            return val\n\nclass TextInput(InputWidget):\n    \"\"\" Single-line input widget. \"\"\"\n\n    value = String(default=\"\", help=\"\"\"\n    Initial or entered text value.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the user unfocuses the TextInput\n    widget by hitting Enter or clicking outside of the text box area.\n    \"\"\")\n\n    placeholder = String(default=\"\", help=\"\"\"\n    Placeholder for empty input field\n    \"\"\")\n\n\nclass AutocompleteInput(TextInput):\n    \"\"\" Single-line input widget with auto-completion. \"\"\"\n\n    completions = List(String, help=\"\"\"\n    A list of completion strings. This will be used to guide the\n    user upon typing the beginning of a desired value.\n    \"\"\")\n\n\nclass Select(InputWidget):\n    \"\"\" Single-select widget.\n\n    \"\"\"\n\n    options = List(Either(String, Tuple(String, String)), help=\"\"\"\n    Available selection options. Options may be provided either as a list of\n    possible string values, or as a list of tuples, each of the form\n    ``(value, label)``. In the latter case, the visible widget text for each\n    value will be corresponding given label.\n    \"\"\")\n\n    value = String(default=\"\", help=\"\"\"\n    Initial or selected value.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Select dropdown\n    value changes.\n    \"\"\")\n\nclass MultiSelect(InputWidget):\n    \"\"\" Multi-select widget.\n\n    \"\"\"\n\n    options = List(Either(String, Tuple(String, String)), help=\"\"\"\n    Available selection options. Options may be provided either as a list of\n    possible string values, or as a list of tuples, each of the form\n    ``(value, label)``. In the latter case, the visible widget text for each\n    value will be corresponding given label.\n    \"\"\")\n\n    value = List(String, help=\"\"\"\n    Initial or selected values.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current selection value\n    changes.\n    \"\"\")\n\n    size = Int(default=4, help=\"\"\"\n    The number of visible options in the dropdown list. (This uses the\n    ``select`` HTML element's ``size`` attribute. Some browsers might not\n    show less than 3 options.)\n    \"\"\")\n\nclass Slider(InputWidget):\n    \"\"\" Slider-based number selection widget.\n\n    \"\"\"\n\n    value = Float(default=0.5, help=\"\"\"\n    Initial or selected value.\n    \"\"\")\n\n    start = Float(default=0, help=\"\"\"\n    The minimum allowable value.\n    \"\"\")\n\n    end = Float(default=1, help=\"\"\"\n    The maximum allowable value.\n    \"\"\")\n\n    step = Float(default=0.1, help=\"\"\"\n    The step between consecutive values.\n    \"\"\")\n\n    orientation = Enum(\"horizontal\", \"vertical\", help=\"\"\"\n    Orient the slider either horizontally (default) or vertically.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Slider value changes.\n    \"\"\")\n\n    callback_throttle = Float(default=200, help=\"\"\"\n    Number of microseconds to pause between callback calls as the slider is moved.\n    \"\"\")\n\n    callback_policy = Enum(SliderCallbackPolicy, default=\"throttle\", help=\"\"\"\n    When the callback is initiated. This parameter can take on only one of three options:\n\n       \"continuous\": the callback will be executed immediately for each movement of the slider\n       \"throttle\": the callback will be executed at most every ``callback_throttle`` milliseconds.\n       \"mouseup\": the callback will be executed only once when the slider is released.\n\n       The `mouseup` policy is intended for scenarios in which the callback is expensive in time.\n    \"\"\")\n\nclass RangeSlider(InputWidget):\n    \"\"\" Range-slider based range selection widget\n\n    \"\"\"\n\n    range = Tuple(Float, Float, default=(0.1, 0.9), help=\"\"\"\n    Initial or selected range.\n    \"\"\")\n\n    start = Float(default=0, help=\"\"\"\n    The minimum allowable value.\n    \"\"\")\n\n    end = Float(default=1, help=\"\"\"\n    The maximum allowable value.\n    \"\"\")\n\n    step = Float(default=0.1, help=\"\"\"\n    The step between consecutive values.\n    \"\"\")\n\n    orientation = Enum(\"horizontal\", \"vertical\", help=\"\"\"\n    Orient the slider either horizontally (default) or vertically.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current Slider value changes.\n    \"\"\")\n\n    callback_throttle = Float(default=200, help=\"\"\"\n    Number of microseconds to pause between callback calls as the slider is moved.\n    \"\"\")\n\n    callback_policy = Enum(SliderCallbackPolicy, default=\"throttle\", help=\"\"\"\n    When the callback is initiated. This parameter can take on only one of three options:\n\n       \"continuous\": the callback will be executed immediately for each movement of the slider\n       \"throttle\": the callback will be executed at most every ``callback_throttle`` milliseconds.\n       \"mouseup\": the callback will be executed only once when the slider is released.\n\n       The `mouseup` policy is intended for scenarios in which the callback is expensive in time.\n    \"\"\")\n\n\nclass DateRangeSlider(InputWidget):\n    \"\"\" Slider-based date range selection widget.\n\n    \"\"\"\n\n    value = Tuple(Date, Date, help=\"\"\"\n    The initial or selected date range.\n    \"\"\")\n\n    bounds = Tuple(Date, Date, help=\"\"\"\n    The earliest and latest allowable dates.\n    \"\"\")\n\n    range = Tuple(RelativeDelta, RelativeDelta, help=\"\"\"\n    [TDB]\n    \"\"\")\n\n    step = RelativeDelta(help=\"\"\"\n    The step between consecutive dates.\n    \"\"\")\n\n    # formatter = Either(String, Function(Date))\n    # scales = DateRangeSliderScales ... # first, next, stop, label, format\n\n    enabled = Bool(True, help=\"\"\"\n    Enable or disable this widget.\n    \"\"\")\n\n    arrows = Bool(True, help=\"\"\"\n    Whether to show clickable arrows on both ends of the slider.\n    \"\"\")\n\n    value_labels = Enum(\"show\", \"hide\", \"change\", help=\"\"\"\n    Show or hide value labels on both sides of the slider.\n    \"\"\")\n\n    wheel_mode = Enum(\"scroll\", \"zoom\", default=None, help=\"\"\"\n    Whether mouse zoom should scroll or zoom selected range (or\n    do nothing).\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever either slider's value changes.\n    \"\"\")\n\nclass DatePicker(InputWidget):\n    \"\"\" Calendar-based date picker widget.\n\n    \"\"\"\n\n    value = Date(help=\"\"\"\n    The initial or picked date.\n    \"\"\")\n\n    min_date = Date(default=None, help=\"\"\"\n    Optional earliest allowable date.\n    \"\"\")\n\n    max_date = Date(default=None, help=\"\"\"\n    Optional latest allowable date.\n    \"\"\")\n\n    callback = Instance(Callback, help=\"\"\"\n    A callback to run in the browser whenever the current date value changes.\n    \"\"\")\n", "path": "bokeh/models/widgets/inputs.py"}, {"content": "from __future__ import print_function\n\nfrom datetime import date\n\nfrom bokeh.document import Document\nfrom bokeh.embed import file_html\nfrom bokeh.resources import INLINE\nfrom bokeh.util.browser import view\nfrom bokeh.models.layouts import Column, Row, WidgetBox\nfrom bokeh.models.widgets import (\n    Button, Toggle, Dropdown,\n    CheckboxGroup, RadioGroup,\n    CheckboxButtonGroup, RadioButtonGroup,\n    TextInput, AutocompleteInput,\n    Select, MultiSelect,\n    Slider, RangeSlider, DateRangeSlider,\n    DatePicker,\n    Paragraph, Div, PreText,\n    Panel, Tabs,\n)\nfrom bokeh.plotting import figure\nfrom bokeh.sampledata.iris import flowers\n\nbutton = Button(label=\"Button (disabled) - still has click event\", button_type=\"primary\", disabled=True)\n\ntoggle = Toggle(label=\"Toggle button\", button_type=\"success\")\n\nmenu = [(\"Item 1\", \"item_1_value\"), (\"Item 2\", \"item_2_value\"), (\"Item 3\", \"item_3_value\")]\ndropdown = Dropdown(label=\"Dropdown button\", button_type=\"warning\", menu=menu, default_value=\"item_1_value\")\n\nsplit_menu = [(\"Item 1\", \"item_1_value\"), (\"Item 2\", \"item_2_value\"), None, (\"Item 3\", \"item_3_value\")]\nsplit = Dropdown(label=\"Split button\", button_type=\"danger\", menu=split_menu)\n\ncheckbox_group = CheckboxGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=[0, 1])\n\nradio_group = RadioGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=0)\n\ncheckbox_button_group = CheckboxButtonGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=[0, 1])\n\nradio_button_group = RadioButtonGroup(labels=[\"Option 1\", \"Option 2\", \"Option 3\"], active=0)\n\ntext_input = TextInput(placeholder=\"Enter value ...\")\n\nautocomplete_input = AutocompleteInput()\n\nselect = Select(options=[\"Option 1\", \"Option 2\", \"Option 3\"])\n\nmulti_select = MultiSelect(options=[\"Option %d\" % (i+1) for i in range(16)], size=6)\n\nslider = Slider(value=10, start=0, end=100)\n\nrange_slider = RangeSlider()\n\n#date_range_slider = DateRangeSlider(value=(date(2016, 1, 1), date(2016, 12, 31)))\n\ndate_picker = DatePicker()\n\nparagraph = Paragraph(text=\"some text\")\n\ndiv = Div(text=\"some <b>text</b>\")\n\npre_text = PreText(text=\"some text\")\n\ndef mk_tab(color):\n    plot = figure(width=300, height=300)\n    plot.scatter(flowers[\"petal_length\"], flowers[\"petal_width\"], color=color, fill_alpha=0.2, size=12)\n    return Panel(title=\"Tab 1: %s\" % color.capitalize(), child=plot)\n\ntabs = Tabs(tabs=[mk_tab(\"red\"), mk_tab(\"green\"), mk_tab(\"blue\")])\n\nwidgets = Row(children=[\n    WidgetBox(children=[\n        button, toggle, dropdown, split,\n        checkbox_group, radio_group,\n        checkbox_button_group, radio_button_group,\n    ]),\n    WidgetBox(children=[\n        text_input, autocomplete_input,\n        select, multi_select,\n        slider, range_slider, #date_range_slider,\n        date_picker,\n        paragraph, div, pre_text,\n    ]),\n    WidgetBox(children=[\n        tabs,\n    ], width=400),\n])\n\ndoc = Document()\ndoc.add_root(widgets)\n\nif __name__ == \"__main__\":\n    doc.validate()\n    filename = \"widgets.html\"\n    with open(filename, \"w\") as f:\n        f.write(file_html(doc, INLINE, \"Widgets\"))\n    print(\"Wrote %s\" % filename)\n    view(filename)\n", "path": "examples/models/widgets.py"}]}