##// END OF EJS Templates
Add None as a widget visible value to allow for visiblity: hidden...
Jason Grout -
Show More
@@ -493,7 +493,14 b' define(["widgets/js/manager",'
493 /**
493 /**
494 * Update visibility
494 * Update visibility
495 */
495 */
496 this.$el.toggle(value);
496 switch(value) {
497 case null: // python None
498 this.$el.show().css('visibility', 'hidden'); break;
499 case false:
500 this.$el.hide(); break;
501 case true:
502 this.$el.show().css('visibility', ''); break;
503 }
497 },
504 },
498
505
499 update_css: function (model, css) {
506 update_css: function (model, css) {
@@ -421,7 +421,7 b' class Widget(LoggingConfigurable):'
421
421
422
422
423 class DOMWidget(Widget):
423 class DOMWidget(Widget):
424 visible = Bool(True, help="Whether the widget is visible.", sync=True)
424 visible = Bool(True, allow_none=True, help="Whether the widget is visible. False collapses the empty space, while None preserves the empty space.", sync=True)
425 _css = Tuple(sync=True, help="CSS property list: (selector, key, value)")
425 _css = Tuple(sync=True, help="CSS property list: (selector, key, value)")
426 _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.")
426 _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.")
427
427
@@ -636,7 +636,10 b''
636 "metadata": {},
636 "metadata": {},
637 "source": [
637 "source": [
638 "Sometimes it is necessary to **hide or show widgets** in place, **without having to re-display** the widget.\n",
638 "Sometimes it is necessary to **hide or show widgets** in place, **without having to re-display** the widget.\n",
639 "The `visibility` property of widgets can be used to hide or show **widgets that have already been displayed** (as seen below)."
639 "The `visible` property of widgets can be used to hide or show **widgets that have already been displayed** (as seen below). The `visible` property can be:\n",
640 "* `True` - the widget is displayed\n",
641 "* `False` - the widget is hidden, and the empty space where the widget would be is collapsed\n",
642 "* `None` - the widget is hidden, and the empty space where the widget would be is shown"
640 ]
643 ]
641 },
644 },
642 {
645 {
@@ -647,8 +650,21 b''
647 },
650 },
648 "outputs": [],
651 "outputs": [],
649 "source": [
652 "source": [
650 "string = widgets.Latex(value=\"Hello World!\")\n",
653 "w1 = widgets.Latex(value=\"First line\")\n",
651 "display(string) "
654 "w2 = widgets.Latex(value=\"Second line\")\n",
655 "w3 = widgets.Latex(value=\"Third line\")\n",
656 "display(w1, w2, w3)"
657 ]
658 },
659 {
660 "cell_type": "code",
661 "execution_count": null,
662 "metadata": {
663 "collapsed": true
664 },
665 "outputs": [],
666 "source": [
667 "w2.visible=None"
652 ]
668 ]
653 },
669 },
654 {
670 {
@@ -659,7 +675,7 b''
659 },
675 },
660 "outputs": [],
676 "outputs": [],
661 "source": [
677 "source": [
662 "string.visible=False"
678 "w2.visible=False"
663 ]
679 ]
664 },
680 },
665 {
681 {
@@ -670,7 +686,7 b''
670 },
686 },
671 "outputs": [],
687 "outputs": [],
672 "source": [
688 "source": [
673 "string.visible=True"
689 "w2.visible=True"
674 ]
690 ]
675 },
691 },
676 {
692 {
@@ -737,15 +753,22 b''
737 ]
753 ]
738 ],
754 ],
739 "kernelspec": {
755 "kernelspec": {
756 "display_name": "Python 2",
757 "name": "python2"
758 },
759 "language_info": {
740 "codemirror_mode": {
760 "codemirror_mode": {
741 "name": "python",
761 "name": "ipython",
742 "version": 2
762 "version": 2
743 },
763 },
744 "display_name": "Python 2",
764 "file_extension": ".py",
745 "language": "python",
765 "mimetype": "text/x-python",
746 "name": "python2"
766 "name": "python",
767 "nbconvert_exporter": "python",
768 "pygments_lexer": "ipython2",
769 "version": "2.7.8"
747 },
770 },
748 "signature": "sha256:8bb091be85fd5e7f76082b1b4b98cddec92a856334935ac2c702fe5ec03f6eff"
771 "signature": "sha256:198630bf2c2eb00401b60a395ebc75049099864b62f0faaf416da02f9808c40b"
749 },
772 },
750 "nbformat": 4,
773 "nbformat": 4,
751 "nbformat_minor": 0
774 "nbformat_minor": 0
General Comments 0
You need to be logged in to leave comments. Login now