Show More
@@ -1,34 +1,34 b'' | |||
|
1 | 1 | """BoolWidget class. |
|
2 | 2 | |
|
3 | 3 | Represents a boolean using a widget. |
|
4 | 4 | """ |
|
5 | 5 | #----------------------------------------------------------------------------- |
|
6 | 6 | # Copyright (c) 2013, the IPython Development Team. |
|
7 | 7 | # |
|
8 | 8 | # Distributed under the terms of the Modified BSD License. |
|
9 | 9 | # |
|
10 | 10 | # The full license is in the file COPYING.txt, distributed with this software. |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | from .widget import DOMWidget |
|
17 | 17 | from IPython.utils.traitlets import Unicode, Bool |
|
18 | 18 | |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | # Classes |
|
21 | 21 | #----------------------------------------------------------------------------- |
|
22 | 22 | class _BoolWidget(DOMWidget): |
|
23 | 23 | value = Bool(False, help="Bool value", sync=True) |
|
24 | 24 | description = Unicode('', help="Description of the boolean (label).", sync=True) |
|
25 | 25 | disabled = Bool(False, help="Enable or disable user changes.", sync=True) |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | class CheckboxWidget(_BoolWidget): |
|
29 | 29 | _view_name = Unicode('CheckboxView', sync=True) |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | class ToggleButtonWidget(_BoolWidget): |
|
33 | 33 | _view_name = Unicode('ToggleButtonView', sync=True) |
|
34 | No newline at end of file | |
|
34 |
@@ -1,36 +1,35 b'' | |||
|
1 |
""" |
|
|
1 | """ImageWidget class. | |
|
2 | 2 | |
|
3 |
Represents a |
|
|
4 | click events on the button and trigger backend code when the clicks are fired. | |
|
3 | Represents an image in the frontend using a widget. | |
|
5 | 4 | """ |
|
6 | 5 | #----------------------------------------------------------------------------- |
|
7 | 6 | # Copyright (c) 2013, the IPython Development Team. |
|
8 | 7 | # |
|
9 | 8 | # Distributed under the terms of the Modified BSD License. |
|
10 | 9 | # |
|
11 | 10 | # The full license is in the file COPYING.txt, distributed with this software. |
|
12 | 11 | #----------------------------------------------------------------------------- |
|
13 | 12 | |
|
14 | 13 | #----------------------------------------------------------------------------- |
|
15 | 14 | # Imports |
|
16 | 15 | #----------------------------------------------------------------------------- |
|
17 | 16 | import base64 |
|
18 | 17 | |
|
19 | 18 | from .widget import DOMWidget |
|
20 | 19 | from IPython.utils.traitlets import Unicode, CUnicode, Bytes |
|
21 | 20 | |
|
22 | 21 | #----------------------------------------------------------------------------- |
|
23 | 22 | # Classes |
|
24 | 23 | #----------------------------------------------------------------------------- |
|
25 | 24 | class ImageWidget(DOMWidget): |
|
26 | 25 | _view_name = Unicode('ImageView', sync=True) |
|
27 | 26 | |
|
28 | 27 | # Define the custom state properties to sync with the front-end |
|
29 | 28 | format = Unicode('png', sync=True) |
|
30 | 29 | width = CUnicode(sync=True) |
|
31 | 30 | height = CUnicode(sync=True) |
|
32 | 31 | _b64value = Unicode(sync=True) |
|
33 | 32 | |
|
34 | 33 | value = Bytes() |
|
35 | 34 | def _value_changed(self, name, old, new): |
|
36 | self._b64value = base64.b64encode(new) No newline at end of file | |
|
35 | self._b64value = base64.b64encode(new) |
General Comments 0
You need to be logged in to leave comments.
Login now