##// END OF EJS Templates
Added ViewWidget
Jonathan Frederic -
Show More
@@ -0,0 +1,27 b''
1 """ViewWidget class.
2
3 Used to display another widget using a different view.
4 """
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
7 #
8 # Distributed under the terms of the Modified BSD License.
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
12
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16 from .widget import BaseWidget
17 from IPython.utils.traitlets import Unicode
18
19 #-----------------------------------------------------------------------------
20 # Classes
21 #-----------------------------------------------------------------------------
22 class ViewWidget(BaseWidget):
23 target_name = Unicode('ViewModel')
24
25 def __init__(self, widget, view):
26 self.default_view_name = view
27 self.widget = widget
@@ -27,6 +27,8 b' from IPython.utils.traitlets import Unicode, Dict, List, Instance, Bool'
27 from IPython.display import Javascript, display
27 from IPython.display import Javascript, display
28 from IPython.utils.py3compat import string_types
28 from IPython.utils.py3compat import string_types
29
29
30 from .widget_view import ViewWidget
31
30 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
31 # Classes
33 # Classes
32 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
@@ -436,3 +438,9 b' class Widget(BaseWidget):'
436 self.send({"msg_type": "remove_class",
438 self.send({"msg_type": "remove_class",
437 "class_list": class_name,
439 "class_list": class_name,
438 "selector": selector})
440 "selector": selector})
441
442
443 def view(self, view_name=None):
444 """Return a widget that can be displayed to display this widget using
445 a non-default view"""
446 return ViewWidget(self, view_name)
General Comments 0
You need to be logged in to leave comments. Login now