From d3462a1f9ed6e6c22829d3d49bcd779ce62a8d51 2014-09-25 03:10:41 From: Sylvain Corlay Date: 2014-09-25 03:10:41 Subject: [PATCH] Set default view to None and never display widget with no view --- diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index 4d2a1e1..4345a41 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -422,8 +422,6 @@ define(["widgets/js/manager", }); - widgetmanager.WidgetManager.register_widget_view('WidgetView', WidgetView); - var DOMWidgetView = WidgetView.extend({ initialize: function (parameters) { // Public constructor @@ -595,7 +593,6 @@ define(["widgets/js/manager", }, }); - widgetmanager.WidgetManager.register_widget_view('DOMWidgetView', DOMWidgetView); var widget = { 'WidgetModel': WidgetModel, diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index a97ec62..e274b46 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -100,7 +100,7 @@ class Widget(LoggingConfigurable): #------------------------------------------------------------------------- _model_name = Unicode('WidgetModel', help="""Name of the backbone model registered in the front-end to create and sync this widget with.""") - _view_name = Unicode('WidgetView', help="""Default view registered in the front-end + _view_name = Unicode(None, allow_none=True, help="""Default view registered in the front-end to use to represent the widget.""", sync=True) comm = Instance('IPython.kernel.comm.Comm') @@ -368,10 +368,10 @@ class Widget(LoggingConfigurable): def _ipython_display_(self, **kwargs): """Called when `IPython.display.display` is called on the widget.""" - # Show view. By sending a display message, the comm is opened and the - # initial state is sent. - self._send({"method": "display"}) - self._handle_displayed(**kwargs) + # Show view. + if self._view_name is not None: + self._send({"method": "display"}) + self._handle_displayed(**kwargs) def _send(self, msg): """Sends a message to the model in the front-end."""