Show More
@@ -553,7 +553,14 b' define(["widgets/js/manager",' | |||||
553 | /** |
|
553 | /** | |
554 | * Update visibility |
|
554 | * Update visibility | |
555 | */ |
|
555 | */ | |
556 |
th |
|
556 | switch(value) { | |
|
557 | case null: // python None | |||
|
558 | this.$el.show().css('visibility', 'hidden'); break; | |||
|
559 | case false: | |||
|
560 | this.$el.hide(); break; | |||
|
561 | case true: | |||
|
562 | this.$el.show().css('visibility', ''); break; | |||
|
563 | } | |||
557 | }, |
|
564 | }, | |
558 |
|
565 | |||
559 | update_css: function (model, css) { |
|
566 | update_css: function (model, css) { |
@@ -428,7 +428,7 b' class Widget(LoggingConfigurable):' | |||||
428 |
|
428 | |||
429 |
|
429 | |||
430 | class DOMWidget(Widget): |
|
430 | class DOMWidget(Widget): | |
431 | visible = Bool(True, help="Whether the widget is visible.", sync=True) |
|
431 | 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) | |
432 | _css = Tuple(sync=True, help="CSS property list: (selector, key, value)") |
|
432 | _css = Tuple(sync=True, help="CSS property list: (selector, key, value)") | |
433 | _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.") |
|
433 | _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.") | |
434 |
|
434 |
@@ -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 `visib |
|
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 |
" |
|
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 |
" |
|
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 |
" |
|
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 |
" |
|
765 | "mimetype": "text/x-python", | |
746 |
"name": "python |
|
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