mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Added visible
property to all widgets
This commit is contained in:
parent
82dd891483
commit
810ea87e5b
@ -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)) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user