Show More
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -1,36 +1,35 b'' | |||||
1 |
""" |
|
1 | """ImageWidget class. | |
2 |
|
2 | |||
3 |
Represents a |
|
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) |
|
35 | self._b64value = base64.b64encode(new) |
General Comments 0
You need to be logged in to leave comments.
Login now