##// END OF EJS Templates
Use CUnicode for width and height in ImageWidget
Jonathan Frederic -
Show More
@@ -1,36 +1,36 b''
1 """ButtonWidget class.
1 """ButtonWidget class.
2
2
3 Represents a button in the frontend using a widget. Allows user to listen for
3 Represents a button in the frontend using a widget. Allows user to listen for
4 click events on the button and trigger backend code when the clicks are fired.
4 click events on the button and trigger backend code when the clicks are fired.
5 """
5 """
6 #-----------------------------------------------------------------------------
6 #-----------------------------------------------------------------------------
7 # Copyright (c) 2013, the IPython Development Team.
7 # Copyright (c) 2013, the IPython Development Team.
8 #
8 #
9 # Distributed under the terms of the Modified BSD License.
9 # Distributed under the terms of the Modified BSD License.
10 #
10 #
11 # The full license is in the file COPYING.txt, distributed with this software.
11 # The full license is in the file COPYING.txt, distributed with this software.
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17 import base64
17 import base64
18
18
19 from .widget import DOMWidget
19 from .widget import DOMWidget
20 from IPython.utils.traitlets import Unicode, Bytes
20 from IPython.utils.traitlets import Unicode, CUnicode, Bytes
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Classes
23 # Classes
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 class ImageWidget(DOMWidget):
25 class ImageWidget(DOMWidget):
26 view_name = Unicode('ImageView', sync=True)
26 view_name = Unicode('ImageView', sync=True)
27
27
28 # Define the custom state properties to sync with the front-end
28 # Define the custom state properties to sync with the front-end
29 format = Unicode('png', sync=True)
29 format = Unicode('png', sync=True)
30 width = Unicode(sync=True) # TODO: C unicode
30 width = CUnicode(sync=True)
31 height = Unicode(sync=True)
31 height = CUnicode(sync=True)
32 _b64value = Unicode(sync=True)
32 _b64value = Unicode(sync=True)
33
33
34 value = Bytes()
34 value = Bytes()
35 def _value_changed(self, name, old, new):
35 def _value_changed(self, name, old, new):
36 self._b64value = base64.b64encode(new) No newline at end of file
36 self._b64value = base64.b64encode(new)
General Comments 0
You need to be logged in to leave comments. Login now