commit
b8c0afbb55
@ -0,0 +1,43 @@
|
||||
|
||||
//
|
||||
// Tests for the Session object
|
||||
//
|
||||
|
||||
casper.notebook_test(function () {
|
||||
this.evaluate(function () {
|
||||
var kernel = IPython.notebook.session.kernel;
|
||||
IPython._channels = [
|
||||
kernel.shell_channel,
|
||||
kernel.iopub_channel,
|
||||
kernel.stdin_channel
|
||||
];
|
||||
IPython.notebook.session.delete();
|
||||
});
|
||||
|
||||
this.waitFor(function () {
|
||||
return this.evaluate(function(){
|
||||
for (var i=0; i < IPython._channels.length; i++) {
|
||||
var ws = IPython._channels[i];
|
||||
if (ws.readyState !== ws.CLOSED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
this.then(function () {
|
||||
var states = this.evaluate(function() {
|
||||
var states = [];
|
||||
for (var i = 0; i < IPython._channels.length; i++) {
|
||||
states.push(IPython._channels[i].readyState);
|
||||
}
|
||||
return states;
|
||||
});
|
||||
|
||||
for (var i = 0; i < states.length; i++) {
|
||||
this.test.assertEquals(states[i], WebSocket.CLOSED,
|
||||
"Session.delete closes websockets[" + i + "]");
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,73 @@
|
||||
"""Box class.
|
||||
|
||||
Represents a container that can be used to group other widgets.
|
||||
"""
|
||||
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget
|
||||
from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
|
||||
class Box(DOMWidget):
|
||||
"""Displays multiple widgets in a group."""
|
||||
_view_name = Unicode('BoxView', sync=True)
|
||||
|
||||
# Child widgets in the container.
|
||||
# Using a tuple here to force reassignment to update the list.
|
||||
# When a proper notifying-list trait exists, that is what should be used here.
|
||||
children = Tuple(sync=True, allow_none=False)
|
||||
|
||||
def __init__(self, children = (), **kwargs):
|
||||
kwargs['children'] = children
|
||||
super(Box, self).__init__(**kwargs)
|
||||
self.on_displayed(Box._fire_children_displayed)
|
||||
|
||||
def _fire_children_displayed(self):
|
||||
for child in self.children:
|
||||
child._handle_displayed()
|
||||
|
||||
|
||||
class Popup(Box):
|
||||
"""Displays multiple widgets in an in page popup div."""
|
||||
_view_name = Unicode('PopupView', sync=True)
|
||||
|
||||
description = Unicode(sync=True)
|
||||
button_text = Unicode(sync=True)
|
||||
|
||||
|
||||
class FlexBox(Box):
|
||||
"""Displays multiple widgets using the flexible box model."""
|
||||
_view_name = Unicode('FlexBoxView', sync=True)
|
||||
orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical', sync=True)
|
||||
flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""")
|
||||
def _flex_changed(self, name, old, new):
|
||||
new = min(max(0, new), 2)
|
||||
if self.flex != new:
|
||||
self.flex = new
|
||||
|
||||
_locations = ['start', 'center', 'end', 'baseline', 'stretch']
|
||||
pack = CaselessStrEnum(
|
||||
values=_locations,
|
||||
default_value='start', allow_none=False, sync=True)
|
||||
align = CaselessStrEnum(
|
||||
values=_locations,
|
||||
default_value='start', allow_none=False, sync=True)
|
||||
|
||||
|
||||
def VBox(*pargs, **kwargs):
|
||||
"""Displays multiple widgets vertically using the flexible box model."""
|
||||
kwargs['orientation'] = 'vertical'
|
||||
return FlexBox(*pargs, **kwargs)
|
||||
|
||||
def HBox(*pargs, **kwargs):
|
||||
"""Displays multiple widgets horizontally using the flexible box model."""
|
||||
kwargs['orientation'] = 'horizontal'
|
||||
return FlexBox(*pargs, **kwargs)
|
||||
|
||||
|
||||
# Remove in IPython 4.0
|
||||
ContainerWidget = DeprecatedClass(Box, 'ContainerWidget')
|
||||
PopupWidget = DeprecatedClass(Popup, 'PopupWidget')
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
"""ContainerWidget class.
|
||||
|
||||
Represents a container that can be used to group other widgets.
|
||||
"""
|
||||
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget
|
||||
from IPython.utils.traitlets import Unicode, Tuple, TraitError
|
||||
|
||||
class ContainerWidget(DOMWidget):
|
||||
_view_name = Unicode('ContainerView', sync=True)
|
||||
|
||||
# Child widgets in the container.
|
||||
# Using a tuple here to force reassignment to update the list.
|
||||
# When a proper notifying-list trait exists, that is what should be used here.
|
||||
children = Tuple(sync=True, allow_none=False)
|
||||
|
||||
def __init__(self, children = (), **kwargs):
|
||||
kwargs['children'] = children
|
||||
super(ContainerWidget, self).__init__(**kwargs)
|
||||
self.on_displayed(ContainerWidget._fire_children_displayed)
|
||||
|
||||
def _fire_children_displayed(self):
|
||||
for child in self.children:
|
||||
child._handle_displayed()
|
||||
|
||||
|
||||
class PopupWidget(ContainerWidget):
|
||||
_view_name = Unicode('PopupView', sync=True)
|
||||
|
||||
description = Unicode(sync=True)
|
||||
button_text = Unicode(sync=True)
|
||||
Loading…
Reference in new issue