Created
March 16, 2015 14:45
-
-
Save patricksnape/ac985babaa9f4df0c7d7 to your computer and use it in GitHub Desktop.
IntText Layout Bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat_minor": 0, "cells": [{"execution_count": 3, "cell_type": "code", "source": "from IPython.html.widgets import IntText, Button, HBox\nfrom IPython.display import display", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 4, "cell_type": "code", "source": "txt = IntText(description='foo')\nbut = Button(description='OK')\nwid = HBox(children=[txt, but])\n\n# This 'properly' flows, the text input area\n# is the correct width, and is flush to the\n# OK button\ndisplay(wid)", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 6, "cell_type": "code", "source": "txt = IntText(description='foo')\nbut = Button(description='OK')\nwid = HBox(children=[txt, but])\n\ndisplay(wid)\n\n# This changes the size of the text input area\n# but NOT the parent div, and therefore an\n# ugly gap appears\n# This is because the parent div that contains\n# both the label 'foo' and the input text has a class\n# (widget-numeric-text) that defines width: 150px\n# which is not overridden by this new width\ntxt.width = '1cm'", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "txt = IntText(description='foo')\nbut = Button(description='OK')\nwid = HBox(children=[txt, but])\n\ndisplay(wid)\n\n# This doesn't increase in size! This is due to the\n# fixed width of 150px if the 'widget-numeric-text' class\ntxt.width = '200cm'", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.9", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment