##// END OF EJS Templates
Merge pull request #5678 from maxalbert/master...
Thomas Kluyver -
r16377:a6406c3c merge
parent child Browse files
Show More
@@ -1,34 +1,34 b''
1 """BoolWidget class.
1 """BoolWidget class.
2
2
3 Represents a boolean using a widget.
3 Represents a boolean using a widget.
4 """
4 """
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2013, the IPython Development Team.
7 #
7 #
8 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
9 #
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16 from .widget import DOMWidget
16 from .widget import DOMWidget
17 from IPython.utils.traitlets import Unicode, Bool
17 from IPython.utils.traitlets import Unicode, Bool
18
18
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Classes
20 # Classes
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 class _BoolWidget(DOMWidget):
22 class _BoolWidget(DOMWidget):
23 value = Bool(False, help="Bool value", sync=True)
23 value = Bool(False, help="Bool value", sync=True)
24 description = Unicode('', help="Description of the boolean (label).", sync=True)
24 description = Unicode('', help="Description of the boolean (label).", sync=True)
25 disabled = Bool(False, help="Enable or disable user changes.", sync=True)
25 disabled = Bool(False, help="Enable or disable user changes.", sync=True)
26
26
27
27
28 class CheckboxWidget(_BoolWidget):
28 class CheckboxWidget(_BoolWidget):
29 _view_name = Unicode('CheckboxView', sync=True)
29 _view_name = Unicode('CheckboxView', sync=True)
30
30
31
31
32 class ToggleButtonWidget(_BoolWidget):
32 class ToggleButtonWidget(_BoolWidget):
33 _view_name = Unicode('ToggleButtonView', sync=True)
33 _view_name = Unicode('ToggleButtonView', sync=True)
34 No newline at end of file
34
@@ -1,36 +1,35 b''
1 """ButtonWidget class.
1 """ImageWidget class.
2
2
3 Represents a button in the frontend using a widget. Allows user to listen for
3 Represents an image in the frontend using a widget.
4 click events on the button and trigger backend code when the clicks are fired.
5 """
4 """
6 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
7 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2013, the IPython Development Team.
8 #
7 #
9 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
10 #
9 #
11 # The full license is in the file COPYING.txt, distributed with this software.
10 # The full license is in the file COPYING.txt, distributed with this software.
12 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
13
12
14 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
15 # Imports
14 # Imports
16 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
17 import base64
16 import base64
18
17
19 from .widget import DOMWidget
18 from .widget import DOMWidget
20 from IPython.utils.traitlets import Unicode, CUnicode, Bytes
19 from IPython.utils.traitlets import Unicode, CUnicode, Bytes
21
20
22 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
23 # Classes
22 # Classes
24 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
25 class ImageWidget(DOMWidget):
24 class ImageWidget(DOMWidget):
26 _view_name = Unicode('ImageView', sync=True)
25 _view_name = Unicode('ImageView', sync=True)
27
26
28 # Define the custom state properties to sync with the front-end
27 # Define the custom state properties to sync with the front-end
29 format = Unicode('png', sync=True)
28 format = Unicode('png', sync=True)
30 width = CUnicode(sync=True)
29 width = CUnicode(sync=True)
31 height = CUnicode(sync=True)
30 height = CUnicode(sync=True)
32 _b64value = Unicode(sync=True)
31 _b64value = Unicode(sync=True)
33
32
34 value = Bytes()
33 value = Bytes()
35 def _value_changed(self, name, old, new):
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