diff --git a/IPython/html/static/notebook/js/widget.js b/IPython/html/static/notebook/js/widget.js
index 7ee4825..177b1cd 100644
--- a/IPython/html/static/notebook/js/widget.js
+++ b/IPython/html/static/notebook/js/widget.js
@@ -307,10 +307,21 @@ define(["components/underscore/underscore-min",
var WidgetView = Backbone.View.extend({
initialize: function() {
+ this.visible = true;
this.model.on('change',this.update,this);
},
update: function() {
+ if (this.model.get('visible') != undefined) {
+ if (this.visible != this.model.get('visible')) {
+ this.visible = this.model.get('visible');
+ if (this.visible) {
+ this.$el.show();
+ } else {
+ this.$el.hide();
+ }
+ }
+ }
if (this.model.css != undefined) {
for (var selector in this.model.css) {
if (this.model.css.hasOwnProperty(selector)) {
diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py
index 4856428..b3eee7a 100644
--- a/IPython/html/widgets/widget.py
+++ b/IPython/html/widgets/widget.py
@@ -21,7 +21,7 @@ import os
import IPython
from IPython.kernel.comm import Comm
from IPython.config import LoggingConfigurable
-from IPython.utils.traitlets import Unicode, Dict, List, Instance
+from IPython.utils.traitlets import Unicode, Dict, List, Instance, Bool
from IPython.display import Javascript, display
from IPython.utils.py3compat import string_types
@@ -50,6 +50,7 @@ class Widget(LoggingConfigurable):
default_view_name = Unicode(help="""Default view registered in the frontend
to use to represent the widget.""")
parent = Instance('IPython.html.widgets.widget.Widget')
+ visible = Bool(True, help="Whether or not the widget is visible.")
def _parent_changed(self, name, old, new):
if self._displayed:
@@ -107,7 +108,7 @@ class Widget(LoggingConfigurable):
# Properties
def _get_keys(self):
- keys = ['_css']
+ keys = ['_css', 'visible']
keys.extend(self._keys)
return keys
keys = property(_get_keys)