├── .npmrc ├── packages ├── output │ ├── .gitignore │ ├── src │ │ ├── index.ts │ │ └── output.ts │ ├── tsconfig.json │ └── package.json ├── base │ ├── .gitignore │ ├── .jshintrc │ ├── .npmignore │ ├── tsconfig.json │ ├── test │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ ├── karma.conf.js │ │ ├── webpack.conf.js │ │ ├── karma-cov.conf.js │ │ └── webpack-cov.conf.js │ ├── src │ │ ├── version.ts │ │ ├── index.ts │ │ └── registry.ts │ └── css │ │ └── index.css ├── html-manager │ ├── .gitignore │ ├── test │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ ├── karma.conf.js │ │ └── webpack.conf.js │ ├── tsconfig.json │ ├── css │ │ └── output.css │ ├── src │ │ ├── embed.ts │ │ ├── embed-amd-render.ts │ │ ├── index.ts │ │ └── output_renderers.ts │ ├── amd-public-path.js │ └── scripts │ │ └── concat-amd-build.js ├── base-manager │ ├── .gitignore │ ├── .jshintrc │ ├── .npmignore │ ├── test │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ ├── karma.conf.js │ │ ├── karma-cov.conf.js │ │ ├── webpack.conf.js │ │ └── webpack-cov.conf.js │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── controls │ ├── .jshintrc │ ├── .gitignore │ ├── .npmignore │ ├── css │ │ ├── widgets.css │ │ └── nouislider.less │ ├── src │ │ ├── version.ts │ │ ├── index.ts │ │ ├── utils.ts │ │ ├── widget_core.ts │ │ └── widget_audio.ts │ ├── test │ │ ├── tsconfig.json │ │ ├── karma.conf.js │ │ ├── src │ │ │ └── index.ts │ │ ├── karma-cov.conf.js │ │ ├── webpack.conf.js │ │ └── webpack-cov.conf.js │ ├── tsconfig.json │ └── README.md └── schema │ ├── README.md │ ├── index.js │ ├── v2 │ └── view.schema.json │ ├── package.json │ └── v1 │ ├── view.schema.json │ └── state.schema.json ├── .prettierrc ├── python ├── ipywidgets │ ├── ipywidgets │ │ ├── tests │ │ │ └── __init__.py │ │ ├── widgets │ │ │ ├── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── data │ │ │ │ │ └── jupyter-logo-transparent.png │ │ │ │ ├── test_widget_button.py │ │ │ │ ├── test_widget_float.py │ │ │ │ ├── test_docutils.py │ │ │ │ ├── test_send_state.py │ │ │ │ ├── test_link.py │ │ │ │ ├── test_widget_box.py │ │ │ │ ├── test_widget_string.py │ │ │ │ └── test_datetime_serializers.py │ │ │ ├── widget_style.py │ │ │ ├── widget_core.py │ │ │ ├── docutils.py │ │ │ ├── widget_color.py │ │ │ ├── valuewidget.py │ │ │ ├── __init__.py │ │ │ ├── widget_description.py │ │ │ └── widget_controller.py │ │ ├── _version.py │ │ ├── view.schema.json │ │ ├── comm.py │ │ └── __init__.py │ ├── pyproject.toml │ ├── setup.py │ ├── MANIFEST.in │ ├── README.md │ ├── LICENSE │ └── setup.cfg ├── jupyterlab_widgets │ ├── .prettierrc │ ├── .eslintignore │ ├── .prettierignore │ ├── .gitignore │ ├── jupyterlab_widgets │ │ ├── _version.py │ │ ├── .gitignore │ │ └── __init__.py │ ├── install.json │ ├── tsconfig.json │ ├── schema │ │ └── plugin.json │ ├── MANIFEST.in │ ├── .cookiecutter_replay │ ├── src │ │ ├── index.ts │ │ └── semvercache.ts │ ├── .eslintrc.js │ └── pyproject.toml └── widgetsnbextension │ ├── .jshintrc │ ├── widgetsnbextension.json │ ├── MANIFEST.in │ ├── widgetsnbextension │ ├── _version.py │ └── __init__.py │ ├── README.md │ ├── src │ ├── widget_output.css │ └── save_state.js │ ├── amd-public-path.js │ ├── pyproject.toml │ ├── webpack.config.js │ ├── setup.py │ ├── setup.cfg │ ├── package.json │ └── LICENSE ├── examples ├── web3 │ ├── .jshintrc │ ├── .gitignore │ ├── tsconfig.json │ ├── scripts │ │ └── copyfiles.js │ ├── src │ │ ├── widgets.css │ │ ├── manager.ts │ │ └── index.ts │ ├── widget_code.json │ ├── webpack.config.js │ ├── README.md │ ├── index.html │ └── package.json ├── web4 │ ├── index.js │ ├── webpack.config.js │ ├── package.json │ └── README.md ├── web2 │ ├── widget_code.py │ ├── webpack.config.js │ ├── package.json │ ├── index.js │ ├── index.html │ ├── README.md │ └── manager.js ├── web1 │ ├── index.html │ ├── webpack.config.js │ ├── README.md │ ├── test │ │ └── index.js │ ├── package.json │ ├── karma.config.js │ ├── manager.js │ └── index.js └── embed-amd │ └── README.md ├── tests └── jlogo-small.png ├── .vscode └── extensions.json ├── docs ├── source │ ├── interact.gif │ ├── explanation │ │ └── index.md │ ├── examples │ │ ├── images │ │ │ ├── flexbox.png │ │ │ ├── widgets.PNG │ │ │ ├── WidgetArch.png │ │ │ ├── grid-area.png │ │ │ ├── grid-cell.png │ │ │ ├── grid-line.png │ │ │ ├── grid-track.png │ │ │ ├── inputoutput.PNG │ │ │ ├── Big.Buck.Bunny.mp3 │ │ │ ├── Big.Buck.Bunny.mp4 │ │ │ ├── ParallelKernels.png │ │ │ ├── WidgetModelView.png │ │ │ ├── grid-start-end-a.png │ │ │ ├── grid-start-end-b.png │ │ │ ├── grid-start-end-d.png │ │ │ ├── VizInteractCompute.png │ │ │ ├── applayout-weather.png │ │ │ ├── gaussian_with_grid.png │ │ │ ├── MultilanguageKernels.png │ │ │ ├── custom-widget-hello.png │ │ │ ├── custom-widget-result.png │ │ │ ├── grid-justify-self-end.png │ │ │ ├── gaussian_with_grid_tiny.png │ │ │ ├── grid-justify-self-start.png │ │ │ ├── grid-justify-self-center.png │ │ │ ├── grid-justify-self-stretch.png │ │ │ ├── flex-container.svg │ │ │ ├── align-self.svg │ │ │ ├── flex-wrap.svg │ │ │ ├── flex-items.svg │ │ │ ├── flex-grow.svg │ │ │ └── flex-direction1.svg │ │ └── Controller.ipynb │ ├── examples.md │ ├── tutorials │ │ └── index.md │ ├── reference │ │ ├── index.md │ │ └── jupyter-widgets.md │ ├── contributing.md │ ├── _static │ │ └── theme.css │ ├── _templates │ │ ├── sidebar-nav-bs-index.html │ │ └── demo.html │ ├── ipywidgets_docs_utils.py │ └── how-to │ │ └── index.md ├── lite │ ├── jupyter-lite.json │ └── jupyter_lite_config.json ├── requirements.txt ├── Readme.md └── environment.yml ├── lerna.json ├── .lintstagedrc ├── .binder ├── postBuild ├── requirements.txt └── README ├── ui-tests ├── tests │ ├── notebooks │ │ └── WidgetArch.png │ ├── widgets.test.ts-snapshots │ │ ├── widgets-cell-0-linux.png │ │ ├── widgets-cell-1-linux.png │ │ ├── widgets-cell-2-linux.png │ │ ├── widgets-cell-3-linux.png │ │ ├── widgets-cell-4-linux.png │ │ ├── widgets-cell-5-linux.png │ │ ├── widgets-cell-6-linux.png │ │ ├── widgets-cell-7-linux.png │ │ ├── widgets-cell-8-linux.png │ │ ├── widgets-cell-9-linux.png │ │ ├── widgets-cell-10-linux.png │ │ ├── widgets-cell-11-linux.png │ │ ├── widgets-cell-12-linux.png │ │ ├── widgets-cell-13-linux.png │ │ ├── widgets-cell-14-linux.png │ │ ├── widgets-cell-15-linux.png │ │ ├── widgets-cell-16-linux.png │ │ ├── widgets-cell-17-linux.png │ │ ├── widgets-cell-18-linux.png │ │ ├── widgets-cell-19-linux.png │ │ ├── widgets-cell-20-linux.png │ │ ├── widgets-cell-21-linux.png │ │ ├── widgets-cell-22-linux.png │ │ ├── widgets-cell-23-linux.png │ │ ├── widgets-cell-24-linux.png │ │ ├── widgets-cell-25-linux.png │ │ ├── widgets-cell-26-linux.png │ │ ├── widgets-cell-27-linux.png │ │ ├── widgets-cell-28-linux.png │ │ ├── widgets-cell-29-linux.png │ │ ├── widgets-cell-30-linux.png │ │ ├── widgets-cell-31-linux.png │ │ ├── widgets-cell-32-linux.png │ │ ├── widgets-cell-33-linux.png │ │ ├── widgets-cell-34-linux.png │ │ ├── widgets-cell-35-linux.png │ │ ├── widgets-cell-36-linux.png │ │ ├── widgets-cell-37-linux.png │ │ ├── widgets-cell-38-linux.png │ │ ├── widgets-cell-39-linux.png │ │ ├── widgets-cell-40-linux.png │ │ ├── widgets-cell-41-linux.png │ │ ├── widgets-cell-42-linux.png │ │ ├── widgets-cell-43-linux.png │ │ └── widgets-cell-44-linux.png │ └── widgets.test.ts ├── jupyter_server_config.py ├── playwright.config.js └── package.json ├── CODE_OF_CONDUCT.md ├── scripts ├── hashes ├── hashes_fedora ├── release_template.txt └── strip_examples.py ├── .readthedocs.yaml ├── .github ├── workflows │ ├── lock.yml │ ├── lint.yml │ ├── answered.yml │ ├── devinstall.yml │ ├── binder-on-pr.yml │ └── build.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── custom_widget_issue.md │ ├── documentation.md │ ├── feature_request.md │ └── bug_report.md └── dependabot.yml ├── typedoc.json ├── tsconfigbase.json ├── tsconfig.typedoc.json ├── .gitignore ├── .yarnrc.yml ├── .eslintrc.json ├── CONTRIBUTING.md ├── LICENSE └── dev-install.sh /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict = true 2 | -------------------------------------------------------------------------------- /packages/output/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/base/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | test/coverage/ 3 | -------------------------------------------------------------------------------- /packages/html-manager/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /examples/web3/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true 3 | } 4 | -------------------------------------------------------------------------------- /packages/output/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './output'; 2 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/web3/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | built/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /packages/base-manager/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | test/coverage/ 3 | -------------------------------------------------------------------------------- /examples/web4/index.js: -------------------------------------------------------------------------------- 1 | require('@jupyter-widgets/html-manager/lib/embed'); 2 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /packages/base/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true, 3 | "expr": true, 4 | "node": true 5 | } 6 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | coverage 4 | **/*.d.ts 5 | tests 6 | -------------------------------------------------------------------------------- /packages/controls/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true, 3 | "expr": true, 4 | "node": true 5 | } 6 | -------------------------------------------------------------------------------- /tests/jlogo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/tests/jlogo-small.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/interact.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/interact.gif -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "independent" 5 | } 6 | -------------------------------------------------------------------------------- /packages/base-manager/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true, 3 | "expr": true, 4 | "node": true 5 | } 6 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | **/node_modules 3 | **/lib 4 | **/package.json 5 | -------------------------------------------------------------------------------- /packages/controls/.gitignore: -------------------------------------------------------------------------------- 1 | css/widgets.built.css 2 | lib-embed/ 3 | docs-embed/ 4 | dist/ 5 | test/coverage/ 6 | -------------------------------------------------------------------------------- /python/widgetsnbextension/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true, 3 | "expr": true, 4 | "node": true 5 | } 6 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "**/*{.ts,.tsx,.js,.jsx,.css,.json}": [ 3 | "prettier --write", 4 | "git add" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.binder/postBuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | npm install -g yarn 6 | yarn set version stable 7 | 8 | ./dev-install.sh 9 | -------------------------------------------------------------------------------- /docs/source/explanation/index.md: -------------------------------------------------------------------------------- 1 | # Explanation 2 | 3 | ```{toctree} 4 | :maxdepth: 1 5 | ../examples/Widget Low Level 6 | ``` 7 | -------------------------------------------------------------------------------- /packages/base/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | test/ 4 | .jshintrc 5 | karma.conf.js 6 | build_css.js 7 | examples/ 8 | -------------------------------------------------------------------------------- /packages/controls/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | test/ 4 | .jshintrc 5 | karma.conf.js 6 | build_css.js 7 | examples/ 8 | -------------------------------------------------------------------------------- /packages/base-manager/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | test/ 4 | .jshintrc 5 | karma.conf.js 6 | build_css.js 7 | examples/ 8 | -------------------------------------------------------------------------------- /docs/source/examples/images/flexbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/flexbox.png -------------------------------------------------------------------------------- /docs/source/examples/images/widgets.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/widgets.PNG -------------------------------------------------------------------------------- /python/widgetsnbextension/widgetsnbextension.json: -------------------------------------------------------------------------------- 1 | { 2 | "load_extensions": { 3 | "jupyter-js-widgets/extension": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /ui-tests/tests/notebooks/WidgetArch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/notebooks/WidgetArch.png -------------------------------------------------------------------------------- /docs/source/examples/images/WidgetArch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/WidgetArch.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-area.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-area.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-cell.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-line.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-track.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-track.png -------------------------------------------------------------------------------- /docs/source/examples/images/inputoutput.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/inputoutput.PNG -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Please refer to [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md). 2 | -------------------------------------------------------------------------------- /docs/source/examples/images/Big.Buck.Bunny.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/Big.Buck.Bunny.mp3 -------------------------------------------------------------------------------- /docs/source/examples/images/Big.Buck.Bunny.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/Big.Buck.Bunny.mp4 -------------------------------------------------------------------------------- /docs/source/examples/images/ParallelKernels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/ParallelKernels.png -------------------------------------------------------------------------------- /docs/source/examples/images/WidgetModelView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/WidgetModelView.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-start-end-a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-start-end-a.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-start-end-b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-start-end-b.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-start-end-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-start-end-d.png -------------------------------------------------------------------------------- /docs/source/examples/images/VizInteractCompute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/VizInteractCompute.png -------------------------------------------------------------------------------- /docs/source/examples/images/applayout-weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/applayout-weather.png -------------------------------------------------------------------------------- /docs/source/examples/images/gaussian_with_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/gaussian_with_grid.png -------------------------------------------------------------------------------- /docs/source/examples/images/MultilanguageKernels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/MultilanguageKernels.png -------------------------------------------------------------------------------- /docs/source/examples/images/custom-widget-hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/custom-widget-hello.png -------------------------------------------------------------------------------- /docs/source/examples/images/custom-widget-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/custom-widget-result.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-justify-self-end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-justify-self-end.png -------------------------------------------------------------------------------- /docs/source/examples/images/gaussian_with_grid_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/gaussian_with_grid_tiny.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-justify-self-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-justify-self-start.png -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.gitignore: -------------------------------------------------------------------------------- 1 | *.bundle.* 2 | lib/ 3 | node_modules/ 4 | *.egg-info/ 5 | .ipynb_checkpoints 6 | *.tsbuildinfo 7 | jupyterlab_widgets/labextension 8 | -------------------------------------------------------------------------------- /docs/source/examples/images/grid-justify-self-center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-justify-self-center.png -------------------------------------------------------------------------------- /docs/source/examples/images/grid-justify-self-stretch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/docs/source/examples/images/grid-justify-self-stretch.png -------------------------------------------------------------------------------- /packages/html-manager/test/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import './output_test'; 5 | -------------------------------------------------------------------------------- /packages/base-manager/test/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import './manager_test'; 5 | -------------------------------------------------------------------------------- /docs/lite/jupyter-lite.json: -------------------------------------------------------------------------------- 1 | { 2 | "jupyter-lite-schema-version": 0, 3 | "jupyter-config-data": { 4 | "disabledExtensions": ["@jupyterlite/javascript-kernel-extension"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/web3/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/*"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/base/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/*"] 8 | } 9 | -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-0-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-0-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-1-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-1-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-2-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-2-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-3-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-3-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-4-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-4-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-5-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-5-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-6-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-6-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-7-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-7-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-8-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-8-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-9-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-9-linux.png -------------------------------------------------------------------------------- /python/jupyterlab_widgets/jupyterlab_widgets/_version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | __version__ = '3.0.16' 5 | -------------------------------------------------------------------------------- /python/widgetsnbextension/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | graft widgetsnbextension/static 3 | graft src 4 | include package.json 5 | include webpack.config.js 6 | include widgetsnbextension.json 7 | -------------------------------------------------------------------------------- /python/widgetsnbextension/widgetsnbextension/_version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | __version__ = '4.0.15' 5 | -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-10-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-10-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-11-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-11-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-12-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-12-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-13-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-13-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-14-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-14-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-15-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-15-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-16-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-16-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-17-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-17-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-18-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-18-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-19-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-19-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-20-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-20-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-21-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-21-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-22-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-22-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-23-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-23-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-24-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-24-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-25-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-25-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-26-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-26-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-27-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-27-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-28-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-28-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-29-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-29-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-30-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-30-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-31-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-31-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-32-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-32-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-33-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-33-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-34-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-34-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-35-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-35-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-36-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-36-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-37-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-37-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-38-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-38-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-39-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-39-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-40-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-40-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-41-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-41-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-42-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-42-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-43-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-43-linux.png -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-44-linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/ui-tests/tests/widgets.test.ts-snapshots/widgets-cell-44-linux.png -------------------------------------------------------------------------------- /packages/base/test/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import './widget_test'; 5 | import './utils_test'; 6 | -------------------------------------------------------------------------------- /packages/base-manager/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export * from './manager-base'; 5 | export * from './utils'; 6 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/data/jupyter-logo-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter-widgets/ipywidgets/HEAD/python/ipywidgets/ipywidgets/widgets/tests/data/jupyter-logo-transparent.png -------------------------------------------------------------------------------- /packages/controls/css/widgets.css: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Jupyter Development Team. 2 | * Distributed under the terms of the Modified BSD License. 3 | */ 4 | 5 | @import './labvariables.css'; 6 | @import './widgets-base.css'; 7 | -------------------------------------------------------------------------------- /ui-tests/jupyter_server_config.py: -------------------------------------------------------------------------------- 1 | from jupyterlab.galata import configure_jupyter_server 2 | 3 | configure_jupyter_server(c) 4 | 5 | # Uncomment to set server log level to debug level 6 | # c.ServerApp.log_level = "DEBUG" 7 | -------------------------------------------------------------------------------- /.binder/requirements.txt: -------------------------------------------------------------------------------- 1 | bqplot 2 | ipyleaflet 3 | jupyterlab-myst 4 | jupyterlab==4.0.7 5 | matplotlib 6 | nbclassic 7 | networkx 8 | notebook==7.0.5 9 | numpy 10 | pandas 11 | scikit-image 12 | scikit-learn 13 | sympy 14 | -------------------------------------------------------------------------------- /packages/schema/README.md: -------------------------------------------------------------------------------- 1 | # Jupyter Widgets Schema 2 | 3 | JSON schema for the json serialization of Jupyter Interactive Widgets. 4 | 5 | ## Package Install 6 | 7 | **Prerequisites** 8 | 9 | - [node](http://nodejs.org/) 10 | -------------------------------------------------------------------------------- /examples/web3/scripts/copyfiles.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | var fs = require('fs-extra'); 5 | fs.copySync('src/widgets.css', 'lib/widgets.css'); 6 | -------------------------------------------------------------------------------- /scripts/hashes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for f in $@ 3 | do 4 | echo "$f" 5 | echo md5: `md5 -q "$f"` 6 | echo sha1: `shasum -a 1 "$f" | awk '{print $1}'` 7 | echo sha256: `shasum -a 256 "$f" | awk '{print $1}'` 8 | echo 9 | done 10 | -------------------------------------------------------------------------------- /examples/web2/widget_code.py: -------------------------------------------------------------------------------- 1 | from ipywidgets import VBox, jsdlink, IntSlider, Button 2 | 3 | s1, s2 = IntSlider(max=200, value=100), IntSlider(value=40) 4 | b = Button(icon='legal') 5 | jsdlink((s1, 'value'), (s2, 'max')) 6 | VBox([s1, s2, b]) 7 | -------------------------------------------------------------------------------- /packages/base/src/version.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export const JUPYTER_WIDGETS_VERSION = '2.0.0'; 5 | 6 | export const PROTOCOL_VERSION = '2.1.0'; 7 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/install.json: -------------------------------------------------------------------------------- 1 | { 2 | "packageManager": "python", 3 | "packageName": "jupyterlab_widgets", 4 | "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_widgets" 5 | } 6 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/jupyterlab_widgets/.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.user 3 | .DS_Store 4 | node_modules 5 | typings/tsd.d.ts 6 | npm-debug.log 7 | test/build 8 | test/coverage 9 | lib 10 | dist 11 | build 12 | docs 13 | example/*.js 14 | static/ 15 | -------------------------------------------------------------------------------- /scripts/hashes_fedora: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for f in $@ 3 | do 4 | echo "$f" 5 | echo md5: `md5sum "$f" | awk '{print $1}'` 6 | echo sha1: `sha1sum "$f" | awk '{print $1}'` 7 | echo sha256: `sha256sum "$f" | awk '{print $1}'` 8 | echo 9 | done 10 | -------------------------------------------------------------------------------- /python/ipywidgets/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | # These are the assumed default build requirements from pip: 3 | # https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support 4 | requires = ["setuptools>=40.8.0", "wheel"] 5 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /packages/base-manager/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/*"], 8 | "references": [ 9 | { 10 | "path": "../base" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/output/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/**/*"], 8 | "references": [ 9 | { 10 | "path": "../base" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/schema/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | v1: { 3 | state: require('./v1/state.schema.json'), 4 | view: require('./v1/view.schema.json'), 5 | }, 6 | v2: { 7 | state: require('./v2/state.schema.json'), 8 | view: require('./v2/view.schema.json'), 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /python/ipywidgets/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) IPython Development Team. 4 | # Copyright (c) Jupyter Development Team. 5 | # Distributed under the terms of the Modified BSD License. 6 | 7 | from setuptools import setup 8 | if __name__ == '__main__': 9 | setup() 10 | -------------------------------------------------------------------------------- /packages/base/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfigbase", 3 | "compilerOptions": { 4 | "types": ["mocha"], 5 | "outDir": "build", 6 | "rootDir": "src" 7 | }, 8 | "include": ["src/*"], 9 | "references": [ 10 | { 11 | "path": ".." 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /docs/source/examples.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | There is a subdirectory called examples in the GitHub repo for `ipywidgets`. In the samples subdirectory are two directories, notebooks and development. 4 | 5 | 7 | -------------------------------------------------------------------------------- /packages/controls/src/version.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | /** 5 | * The version of the Jupyter controls widget attribute spec that this package 6 | * implements. 7 | */ 8 | export const JUPYTER_CONTROLS_VERSION = '2.0.0'; 9 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: 'ubuntu-22.04' 5 | tools: 6 | python: 'mambaforge-4.10' 7 | python: 8 | install: 9 | - method: pip 10 | path: ./python/ipywidgets 11 | conda: 12 | environment: docs/environment.yml 13 | sphinx: 14 | configuration: docs/source/conf.py 15 | -------------------------------------------------------------------------------- /docs/source/tutorials/index.md: -------------------------------------------------------------------------------- 1 | # Tutorials 2 | 3 | ```{toctree} 4 | :caption: For Custom Widget Authors 5 | :maxdepth: 1 6 | ../examples/Widget Custom 7 | ``` 8 | 9 | ```{hint} 10 | For a more in-depth tutorial, see the 11 | [dedicated GitHub repository](https://github.com/jupyter-widgets/tutorial). 12 | ``` 13 | -------------------------------------------------------------------------------- /packages/base-manager/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfigbase", 3 | "compilerOptions": { 4 | "types": ["mocha"], 5 | "outDir": "build", 6 | "rootDir": "src" 7 | }, 8 | "include": ["src/*"], 9 | "references": [ 10 | { 11 | "path": ".." 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/controls/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfigbase", 3 | "compilerOptions": { 4 | "types": ["mocha"], 5 | "outDir": "build", 6 | "rootDir": "src" 7 | }, 8 | "include": ["src/**/*"], 9 | "references": [ 10 | { 11 | "path": ".." 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/html-manager/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfigbase", 3 | "compilerOptions": { 4 | "types": ["mocha"], 5 | "outDir": "build", 6 | "rootDir": "src" 7 | }, 8 | "include": ["src/*"], 9 | "references": [ 10 | { 11 | "path": ".." 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/controls/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src", 6 | "types": ["mathjax", "node"] 7 | }, 8 | "include": ["src/**/*"], 9 | "references": [ 10 | { 11 | "path": "../base" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /docs/source/reference/index.md: -------------------------------------------------------------------------------- 1 | # Reference 2 | 3 | ```{toctree} 4 | :caption: History 5 | :maxdepth: 1 6 | ../changelog 7 | ``` 8 | 9 | ```{toctree} 10 | :caption: Python API 11 | :maxdepth: 1 12 | ipywidgets 13 | ../genindex 14 | ../modindex 15 | ``` 16 | 17 | ```{toctree} 18 | :caption: JS API 19 | :maxdepth: 1 20 | jupyter-widgets 21 | ``` 22 | -------------------------------------------------------------------------------- /ui-tests/playwright.config.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | timeout: 240000, 6 | webServer: { 7 | command: 'jlpm start', 8 | url: 'http://localhost:8888/lab', 9 | timeout: 120 * 1000, 10 | reuseExistingServer: !process.env.CI, 11 | }, 12 | retries: 1, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/controls/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath: '..', 4 | frameworks: ['mocha'], 5 | reporters: ['mocha'], 6 | files: ['test/build/bundle.js'], 7 | port: 9876, 8 | colors: true, 9 | singleRun: true, 10 | logLevel: config.LOG_INFO, 11 | browserNoActivityTimeout: 30000, 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/base-manager/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath: '..', 4 | frameworks: ['mocha'], 5 | reporters: ['mocha'], 6 | files: ['test/build/bundle.js'], 7 | port: 9876, 8 | colors: true, 9 | singleRun: true, 10 | logLevel: config.LOG_INFO, 11 | browserNoActivityTimeout: 30000, 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/html-manager/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath: '..', 4 | frameworks: ['mocha'], 5 | reporters: ['mocha'], 6 | files: ['test/build/bundle.js'], 7 | port: 9876, 8 | colors: true, 9 | singleRun: true, 10 | logLevel: config.LOG_INFO, 11 | browserNoActivityTimeout: 30000, 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/controls/test/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import './widget_date_test'; 5 | import './widget_datetime_test'; 6 | import './widget_time_test'; 7 | import './widget_selection_test'; 8 | import './widget_string_test'; 9 | import './widget_upload_test'; 10 | import './lumino/currentselection_test'; 11 | -------------------------------------------------------------------------------- /examples/web3/src/widgets.css: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Jupyter Development Team. 2 | * Distributed under the terms of the Modified BSD License. 3 | */ 4 | 5 | /* 6 | * This example shows how to customize the theming and still compile the CSS 7 | * down to something that all browsers support. 8 | */ 9 | @import '@jupyter-widgets/controls/css/widgets.css'; 10 | :root { 11 | --jp-widgets-border-width: 2px; 12 | } 13 | -------------------------------------------------------------------------------- /examples/web1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Widget Example 1

8 |

In this widget example, you will see a text box widget and a rendered HTML widget which are linked together. Type into the text box to see the HTML widget automatically updated. 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/web1/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var webpack = require('webpack'); 3 | 4 | module.exports = { 5 | mode: 'development', 6 | devtool: 'source-map', 7 | entry: './index.js', 8 | output: { 9 | filename: 'index.built.js', 10 | path: path.resolve(__dirname, 'built'), 11 | }, 12 | module: { 13 | rules: [{ test: /\.css$/i, use: ['style-loader', 'css-loader'] }], 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/**/*"], 8 | "references": [ 9 | { 10 | "path": "../../packages/base" 11 | }, 12 | { 13 | "path": "../../packages/controls" 14 | }, 15 | { 16 | "path": "../../packages/output" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /packages/base/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath: '..', 4 | frameworks: ['mocha'], 5 | reporters: ['mocha'], 6 | mochaReporter: { 7 | showDiff: true, 8 | }, 9 | files: ['test/build/bundle.js'], 10 | port: 9876, 11 | colors: true, 12 | singleRun: true, 13 | logLevel: config.LOG_INFO, 14 | browserNoActivityTimeout: 30000, 15 | }); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/html-manager/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfigbase", 3 | "compilerOptions": { 4 | "outDir": "lib", 5 | "rootDir": "src" 6 | }, 7 | "include": ["src/*"], 8 | "references": [ 9 | { 10 | "path": "../base" 11 | }, 12 | { 13 | "path": "../base-manager" 14 | }, 15 | { 16 | "path": "../controls" 17 | }, 18 | { 19 | "path": "../output" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/base/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export * from './widget'; 5 | export * from './manager'; 6 | export * from './widget_layout'; 7 | export * from './widget_style'; 8 | export * from './services-shim'; 9 | export * from './viewlist'; 10 | export * from './version'; 11 | export * from './utils'; 12 | export * from './registry'; 13 | export * from './errorwidget'; 14 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/schema/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Jupyter Widgets", 3 | "description": "Jupyter widgets settings.", 4 | "additionalProperties": false, 5 | "properties": { 6 | "saveState": { 7 | "type": "boolean", 8 | "title": "Save Jupyter widget state in notebooks", 9 | "description": "Automatically save Jupyter widget state when a notebook is saved.", 10 | "default": false 11 | } 12 | }, 13 | "type": "object" 14 | } 15 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_widget_button.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | import inspect 5 | import pytest 6 | from ipywidgets import Button 7 | 8 | def test_deprecation_fa_icons(): 9 | with pytest.deprecated_call() as record: 10 | Button(icon='fa-home') 11 | assert len(record) == 1 12 | assert record[0].filename == inspect.stack(context=0)[1].filename 13 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: 'Lock Closed Threads' 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: dessant/lock-threads@v2 12 | with: 13 | github-token: ${{ github.token }} 14 | issue-lock-inactive-days: '90' 15 | issue-lock-labels: 'resolved-locked' 16 | pr-lock-inactive-days: '90' 17 | pr-lock-labels: 'resolved-locked' 18 | -------------------------------------------------------------------------------- /.binder/README: -------------------------------------------------------------------------------- 1 | This directory holds configuration files for https://mybinder.org/. 2 | 3 | The interactive notebooks can be accessed with this link: 4 | https://mybinder.org/v2/gh/jupyter-widgets/ipywidgets/main?filepath=docs/source/examples 5 | 6 | To check out a different version, just replace `main` with the desired 7 | branch/tag name or commit hash. 8 | 9 | To use JupyterLab, use: 10 | https://mybinder.org/v2/gh/jupyter-widgets/ipywidgets/main?urlpath=lab/tree/docs/source/examples 11 | -------------------------------------------------------------------------------- /docs/lite/jupyter_lite_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "LiteBuildConfig": { 3 | "extra_ignore_contents": [ 4 | "Layout Example\\.ipynb", 5 | "Layout Templates\\.ipynb", 6 | "Variable Inspector\\.ipynb" 7 | ], 8 | "contents": ["../source/examples"] 9 | }, 10 | "PipliteAddon": { 11 | "piplite_urls": [ 12 | "../../python/ipywidgets/dist", 13 | "../../python/widgetsnbextension/dist", 14 | "../../python/jupyterlab_widgets/dist" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docs/source/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | The ipywidgets package is under the [Jupyter-Widgets](https://github.com/jupyter-widgets) [software subproject](https://jupyter.org/governance/software_subprojects.html). 4 | 5 | We appreciate contributions from the community. 6 | 7 | We follow the [IPython Contributing Guide](https://github.com/ipython/ipython/blob/main/CONTRIBUTING.md) 8 | and [Jupyter Contributing Guides](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html). 9 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://typedoc.org/schema.json", 3 | "entryPointStrategy": "packages", 4 | "entryPoints": [ 5 | "packages/base", 6 | "packages/base-manager", 7 | "packages/controls", 8 | "packages/html-manager", 9 | "packages/output", 10 | "python/jupyterlab_widgets" 11 | ], 12 | "githubPages": false, 13 | "logLevel": "Verbose", 14 | "name": "jupyter-widgets", 15 | "out": "docs/typedoc/typedoc", 16 | "tsconfig": "tsconfig.typedoc.json" 17 | } 18 | -------------------------------------------------------------------------------- /packages/html-manager/css/output.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | | Copyright (c) Jupyter Development Team. 3 | | Distributed under the terms of the Modified BSD License. 4 | |----------------------------------------------------------------------------*/ 5 | 6 | /* */ 7 | .jupyter-widgets.widget-output .jp-OutputArea-prompt, /* */ 8 | .jupyter-widgets.jupyter-widget-output .jp-OutputArea-prompt { 9 | display: none; 10 | } 11 | -------------------------------------------------------------------------------- /packages/html-manager/src/embed.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { HTMLManager } from './index'; 5 | 6 | import { renderWidgets } from './libembed'; 7 | 8 | // Render the widgets that we can 9 | if (!(window as any)._jupyter_widget_embedder) { 10 | (window as any)._jupyter_widget_embedder = true; 11 | window.addEventListener('load', () => { 12 | renderWidgets(() => new HTMLManager()); 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md 3 | include pyproject.toml 4 | 5 | include package.json 6 | include install.json 7 | include ts*.json 8 | 9 | recursive-include labextension *.* 10 | 11 | # Javascript files 12 | prune src 13 | prune style 14 | prune **/node_modules 15 | prune lib 16 | 17 | # Patterns to exclude from any directory 18 | global-exclude *~ 19 | global-exclude *.pyc 20 | global-exclude *.pyo 21 | global-exclude .git 22 | global-exclude .ipynb_checkpoints 23 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | bqplot 2 | build 3 | docutils >=0.19 4 | ipykernel 5 | ipyleaflet 6 | jupyter-client 7 | jupyter-packaging 8 | jupyterlab >=4 9 | jupyterlite-core >=0.3.0,<0.4.0 10 | jupyterlite-pyodide-kernel >=0.3.0,<0.4.0 11 | matplotlib 12 | myst-nb >=0.17,<0.18 13 | numpy 14 | packaging 15 | pkginfo 16 | pydata-sphinx-theme 17 | recommonmark 18 | scikit-image 19 | scikit-learn 20 | sphinx >=1.4.6 21 | sphinx-autobuild 22 | sphinx-autodoc-typehints 23 | sphinx-copybutton 24 | sphinxext-rediraffe 25 | sympy 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser 2 | blank_issues_enabled: true # default 3 | contact_links: 4 | - name: Question/Support/Other 5 | url: https://discourse.jupyter.org/c/widgets/46 6 | about: If you have a usage question 7 | - name: Chat with devs 8 | url: https://gitter.im/jupyter-widgets/Lobby 9 | about: Ask short questions about using or creating widgets 10 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.cookiecutter_replay: -------------------------------------------------------------------------------- 1 | { 2 | "cookiecutter": { 3 | "author_name": "Jupyter Development Team", 4 | "python_name": "jupyterlab_widgets", 5 | "labextension_name": "@jupyter-widgets/jupyterlab-manager", 6 | "project_short_description": "A JupyterLab extension.", 7 | "has_server_extension": "n", 8 | "has_binder": "n", 9 | "repository": "https://github.com/jupyter-widgets/ipywidgets", 10 | "_template": "https://github.com/jupyterlab/extension-cookiecutter-ts" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/html-manager/src/embed-amd-render.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | (window as any).require( 5 | ['@jupyter-widgets/html-manager/dist/libembed-amd'], 6 | function (embed: { renderWidgets: { (): void; (): void } }) { 7 | if (document.readyState === 'complete') { 8 | embed.renderWidgets(); 9 | } else { 10 | window.addEventListener('load', function () { 11 | embed.renderWidgets(); 12 | }); 13 | } 14 | } 15 | ); 16 | -------------------------------------------------------------------------------- /python/widgetsnbextension/README.md: -------------------------------------------------------------------------------- 1 | # Jupyter Widgets for Jupyter Notebook 2 | 3 | [![Version](https://img.shields.io/pypi/v/ipywidgets.svg?logo=pypi)](https://pypi.python.org/pypi/ipywidgets) 4 | 5 | This package makes Jupyter widgets available in the classic Jupyter Notebook. This package provides the necessary JavaScript controls in the Jupyter Notebook that communicate with the widget objects in the kernel. 6 | 7 | Install the corresponding Jupyter widgets package into your kernel, i.e., IPython users would install `ipywidgets` into their kernel. 8 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import WidgetManagerProvider from './plugin'; 5 | import * as output from './output'; 6 | 7 | export default WidgetManagerProvider; 8 | 9 | export { registerWidgetManager } from './plugin'; 10 | 11 | export { 12 | KernelWidgetManager, 13 | LabWidgetManager, 14 | WidgetManager, 15 | } from './manager'; 16 | 17 | export { WidgetRenderer } from './renderer'; 18 | 19 | export { output }; 20 | -------------------------------------------------------------------------------- /packages/controls/README.md: -------------------------------------------------------------------------------- 1 | # Jupyter JS Widgets 2 | 3 | Interactive widgets for the Jupyter notebook. 4 | 5 | This packages contains the implementation of the core Jupyter interactive 6 | widgets. 7 | 8 | The reference Python backend, `ipywidgets` is available 9 | [here](https://github.com/jupyter-widgets/ipywidgets), with more examples. 10 | 11 | ## Package Install 12 | 13 | **Prerequisites** 14 | 15 | - [node](http://nodejs.org/) 16 | 17 | Run the following command **at the root of this repository**. 18 | 19 | ```bash 20 | npm install --save @jupyter-widgets/controls 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/web1/README.md: -------------------------------------------------------------------------------- 1 | # Ad hoc widget manager for using Jupyter widgets in a plain web page 2 | 3 | ## Description 4 | 5 | This directory is an example project that shows how to use the 6 | Jupyter widgets library in a pure JavaScript context. 7 | 8 | This example implements a simple widget manager 9 | by extending the base widget manager from the `@jupyter-widgets/base` library. 10 | 11 | ## Try it 12 | 13 | 1. Start with a repository checkout, and run `yarn install` in the root directory. 14 | 2. Run `yarn build:examples` in the root directory. 15 | 3. Open the `index.html` file in this directory. 16 | -------------------------------------------------------------------------------- /packages/html-manager/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export * from './htmlmanager'; 5 | export { requireLoader } from './libembed-amd'; 6 | 7 | export const version = require('../package.json').version; 8 | 9 | export function generateEmbedScript( 10 | widgetState: any, 11 | imageDataUrl: string 12 | ): string { 13 | return ` 14 | `; 17 | } 18 | -------------------------------------------------------------------------------- /python/ipywidgets/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include CONTRIBUTING.md 3 | include README.md 4 | include package.json 5 | 6 | # Documentation 7 | graft docs 8 | exclude docs/\#* 9 | 10 | # Tests 11 | graft ipywidgets/tests 12 | 13 | # Static Assets 14 | graft ipywidgets/static 15 | 16 | # Docs subdirs we want to skip 17 | prune docs/build 18 | prune docs/dist 19 | 20 | # Patterns to exclude from any directory 21 | global-exclude *~ 22 | global-exclude *.pyc 23 | global-exclude *.pyo 24 | global-exclude .git 25 | global-exclude .ipynb_checkpoints 26 | 27 | # Exclude build scripts 28 | exclude scripts 29 | -------------------------------------------------------------------------------- /examples/web4/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var webpack = require('webpack'); 3 | 4 | module.exports = { 5 | mode: 'development', 6 | devtool: 'source-map', 7 | entry: './index.js', 8 | output: { 9 | filename: 'index.built.js', 10 | path: path.resolve(__dirname, 'built'), 11 | }, 12 | module: { 13 | rules: [ 14 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 15 | // required to load font-awesome 16 | { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' }, 17 | { test: /\.svg$/i, type: 'asset' }, 18 | ], 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /python/widgetsnbextension/src/widget_output.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Jupyter Development Team. 3 | * Distributed under the terms of the Modified BSD License. 4 | */ 5 | 6 | /* Override the correction for the prompt area in https://github.com/jupyter/notebook/blob/dd41d9fd5c4f698bd7468612d877828a7eeb0e7a/IPython/html/static/notebook/less/outputarea.less#L110 */ 7 | .jupyter-widgets-output-area div.output_subarea { 8 | max-width: 100%; 9 | } 10 | 11 | /* Work-around for the bug fixed in https://github.com/jupyter/notebook/pull/2961 */ 12 | .jupyter-widgets-output-area > .out_prompt_overlay { 13 | display: none; 14 | } 15 | -------------------------------------------------------------------------------- /packages/base-manager/test/karma-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = function (config) { 4 | config.set({ 5 | basePath: '..', 6 | browsers: ['Firefox'], 7 | frameworks: ['mocha'], 8 | reporters: ['mocha', 'coverage'], 9 | files: ['test/build/coverage.js'], 10 | coverageReporter: { 11 | reporters: [ 12 | { type: 'text' }, 13 | { type: 'lcov', dir: 'test/coverage' }, 14 | { type: 'html', dir: 'test/coverage' }, 15 | ], 16 | }, 17 | port: 9876, 18 | colors: true, 19 | singleRun: true, 20 | logLevel: config.LOG_INFO, 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/controls/test/karma-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = function (config) { 4 | config.set({ 5 | basePath: '..', 6 | browsers: ['Firefox'], 7 | frameworks: ['mocha'], 8 | reporters: ['mocha', 'coverage'], 9 | files: ['test/build/coverage.js'], 10 | coverageReporter: { 11 | reporters: [ 12 | { type: 'text' }, 13 | { type: 'lcov', dir: 'test/coverage' }, 14 | { type: 'html', dir: 'test/coverage' }, 15 | ], 16 | }, 17 | port: 9876, 18 | colors: true, 19 | singleRun: true, 20 | logLevel: config.LOG_INFO, 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /examples/web3/widget_code.json: -------------------------------------------------------------------------------- 1 | [ 2 | "from ipywidgets import IntSlider, Output, Text, VBox", 3 | "from IPython.display import Image, display", 4 | "", 5 | "s = IntSlider(min=1, max=500, value=200, description='Width')", 6 | "t = Text(description='Area', disabled=True)", 7 | "o = Output()", 8 | "display(VBox([s, t, o]))", 9 | "", 10 | "def update(change=None):", 11 | " width = s.value", 12 | " t.value = str(width ** 2)", 13 | " o.outputs = ()", 14 | " img = Image(url='jupyter-logo.svg', width=width)", 15 | " o.append_display_data(img)", 16 | "", 17 | "s.observe(update, names='value')", 18 | "update()" 19 | ] 20 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | name: Lint 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v4 12 | 13 | - name: Install Python 14 | uses: actions/setup-python@v4 15 | with: 16 | python-version: '3.13' 17 | architecture: 'x64' 18 | 19 | - name: Install dependencies 20 | run: | 21 | python -m pip install jupyterlab 22 | 23 | - name: yarn install, integrity, lint 24 | run: | 25 | jlpm --immutable 26 | jlpm integrity 27 | jlpm lint:check 28 | -------------------------------------------------------------------------------- /docs/source/_static/theme.css: -------------------------------------------------------------------------------- 1 | /* index */ 2 | table.indextable tr.cap { 3 | background-color: var(--pst-color-on-background) !important; 4 | } 5 | 6 | /* demo */ 7 | #demo-sidebar { 8 | margin: 0; 9 | } 10 | 11 | #demo-sidebar .demo-app { 12 | display: inline; 13 | display: flex; 14 | flex-direction: row; 15 | align-items: baseline; 16 | flex-wrap: wrap; 17 | margin: 0.75rem 0.25rem 0 0.25rem; 18 | } 19 | 20 | .demo-app > * { 21 | flex: 1 auto; 22 | white-space: nowrap; 23 | } 24 | 25 | #demo-sidebar .admonition-title::after { 26 | display: none; 27 | } 28 | 29 | #demo-sidebar .admonition-title { 30 | padding-left: 0.75rem; 31 | } 32 | -------------------------------------------------------------------------------- /examples/web2/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var webpack = require('webpack'); 3 | 4 | module.exports = { 5 | mode: 'development', 6 | devtool: 'source-map', 7 | entry: './index.js', 8 | output: { 9 | filename: 'index.built.js', 10 | path: path.resolve(__dirname, 'built'), 11 | }, 12 | module: { 13 | rules: [ 14 | { test: /\.css$/i, use: ['style-loader', 'css-loader'] }, 15 | { test: /\.py$/i, type: 'asset/source' }, 16 | // required to load font-awesome 17 | { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' }, 18 | { test: /\.svg$/i, type: 'asset' }, 19 | ], 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/widget_style.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Contains the Style class""" 5 | 6 | from traitlets import Unicode 7 | from .widget import Widget 8 | from .._version import __jupyter_widgets_base_version__ 9 | 10 | class Style(Widget): 11 | """Style specification""" 12 | 13 | _model_name = Unicode('StyleModel').tag(sync=True) 14 | _view_name = Unicode('StyleView').tag(sync=True) 15 | _view_module = Unicode('@jupyter-widgets/base').tag(sync=True) 16 | _view_module_version = Unicode(__jupyter_widgets_base_version__).tag(sync=True) 17 | -------------------------------------------------------------------------------- /packages/output/src/output.ts: -------------------------------------------------------------------------------- 1 | import { DOMWidgetModel, DOMWidgetView } from '@jupyter-widgets/base'; 2 | 3 | export const OUTPUT_WIDGET_VERSION = '1.0.0'; 4 | 5 | export class OutputModel extends DOMWidgetModel { 6 | defaults(): Backbone.ObjectHash { 7 | return { 8 | ...super.defaults(), 9 | _model_name: 'OutputModel', 10 | _view_name: 'OutputView', 11 | _model_module: '@jupyter-widgets/output', 12 | _view_module: '@jupyter-widgets/output', 13 | _model_module_version: OUTPUT_WIDGET_VERSION, 14 | _view_module_version: OUTPUT_WIDGET_VERSION, 15 | }; 16 | } 17 | } 18 | 19 | export class OutputView extends DOMWidgetView {} 20 | -------------------------------------------------------------------------------- /packages/base/test/webpack.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'bundle.js', 8 | }, 9 | bail: true, 10 | module: { 11 | rules: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | }, 22 | mode: 'development', 23 | resolve: { fallback: { util: false } }, 24 | }; 25 | -------------------------------------------------------------------------------- /packages/schema/v2/view.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "description": "Jupyter Interactive Widget View JSON schema.", 4 | "type": "object", 5 | "properties": { 6 | "version_major": { 7 | "description": "Format version (major)", 8 | "type": "number", 9 | "minimum": 2, 10 | "maximum": 2 11 | }, 12 | "version_minor": { 13 | "description": "Format version (minor)", 14 | "type": "number" 15 | }, 16 | "model_id": { 17 | "description": "Unique identifier of the widget model to be displayed", 18 | "type": "string" 19 | } 20 | }, 21 | "required": ["model_id"] 22 | } 23 | -------------------------------------------------------------------------------- /packages/controls/test/webpack.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'bundle.js', 8 | }, 9 | bail: true, 10 | module: { 11 | rules: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | }, 22 | mode: 'development', 23 | resolve: { fallback: { util: false } }, 24 | }; 25 | -------------------------------------------------------------------------------- /packages/base-manager/test/webpack.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'bundle.js', 8 | }, 9 | bail: true, 10 | module: { 11 | rules: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | }, 22 | mode: 'development', 23 | resolve: { fallback: { util: false } }, 24 | }; 25 | -------------------------------------------------------------------------------- /packages/base/test/karma-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = function (config) { 4 | config.set({ 5 | basePath: '..', 6 | browsers: ['Firefox'], 7 | frameworks: ['mocha'], 8 | reporters: ['mocha', 'coverage'], 9 | files: ['test/build/coverage.js'], 10 | coverageReporter: { 11 | reporters: [ 12 | { type: 'text' }, 13 | { type: 'lcov', dir: 'test/coverage' }, 14 | { type: 'html', dir: 'test/coverage' }, 15 | ], 16 | }, 17 | mochaReporter: { 18 | showDiff: true, 19 | }, 20 | port: 9876, 21 | colors: true, 22 | singleRun: true, 23 | logLevel: config.LOG_INFO, 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/html-manager/amd-public-path.js: -------------------------------------------------------------------------------- 1 | // In an AMD module, we set the public path using the magic requirejs 'module' dependency 2 | // See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module 3 | // Since 'module' is a requirejs magic module, we must include 'module' in the webpack externals configuration. 4 | var module = require('module'); 5 | var url = new URL(module.uri, document.location); 6 | // Using lastIndexOf('/')+1 gives us the empty string if there is no '/', so pathname becomes '/' 7 | url.pathname = url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1); 8 | __webpack_public_path__ = `${url.origin}${url.pathname}`; 9 | -------------------------------------------------------------------------------- /python/widgetsnbextension/amd-public-path.js: -------------------------------------------------------------------------------- 1 | // In an AMD module, we set the public path using the magic requirejs 'module' dependency 2 | // See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module 3 | // Since 'module' is a requirejs magic module, we must include 'module' in the webpack externals configuration. 4 | var module = require('module'); 5 | var url = new URL(module.uri, document.location); 6 | // Using lastIndexOf('/')+1 gives us the empty string if there is no '/', so pathname becomes '/' 7 | url.pathname = url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1); 8 | __webpack_public_path__ = `${url.origin}${url.pathname}`; 9 | -------------------------------------------------------------------------------- /scripts/release_template.txt: -------------------------------------------------------------------------------- 1 | ### [v{{ version }}](https://github.com/jupyter-widgets/ipywidgets/releases/tag/v{{ version }}) ({{ close_date }}) 2 | 3 | See the [ipywidgets 4 | {{ version }}](https://github.com/jupyter-widgets/ipywidgets/milestone/XXXX?closed=1) 5 | milestone on GitHub for the full list of pull requests and issues closed. 6 | 7 | {% for pr in pull_requests -%} 8 | * {{ pr['title'] | capitalize }} ([#{{ pr['number'] }}]({{pr['html_url']}}) 9 | {%- if pr['loghub_related_issues']|length %} 10 | {%- for pri in pr['loghub_related_issues'] -%} 11 | , [#{{ pri['text'] }}]({{ pri['url'] }}) 12 | {%- endfor -%} 13 | {%- endif %}) 14 | {% endfor %} 15 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/_version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | __version__ = '8.1.8' 5 | 6 | __protocol_version__ = '2.1.0' 7 | __control_protocol_version__ = '1.0.0' 8 | 9 | # These are *protocol* versions for each package, *not* npm versions. To check, look at each package's src/version.ts file for the protocol version the package implements. 10 | __jupyter_widgets_base_version__ = '2.0.0' 11 | __jupyter_widgets_output_version__ = '1.0.0' 12 | __jupyter_widgets_controls_version__ = '2.0.0' 13 | 14 | # A compatible @jupyter-widgets/html-manager npm package semver range 15 | __html_manager_version__ = '^1.0.1' 16 | -------------------------------------------------------------------------------- /python/widgetsnbextension/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | # These are the assumed default build requirements from pip: 3 | # https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support 4 | requires = ["jupyter_packaging~=0.10,<2"] 5 | 6 | [tool.jupyter-packaging.options] 7 | skip-if-exists = ["widgetnbextension/static/extension.js"] 8 | ensured-targets = ["widgetnbextension/static/extension.js"] 9 | 10 | [tool.jupyter-packaging.builder] 11 | factory = "jupyter_packaging.npm_builder" 12 | 13 | [tool.jupyter-packaging.build-args] 14 | build_cmd = "build" 15 | npm = ["yarn"] 16 | 17 | [tool.check-manifest] 18 | ignore = ["widgetnbextension/static/**", "yarn.lock", ".*", "package-lock.json"] 19 | -------------------------------------------------------------------------------- /docs/source/_templates/sidebar-nav-bs-index.html: -------------------------------------------------------------------------------- 1 | 10 | 11 |

25 | -------------------------------------------------------------------------------- /packages/schema/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/schema", 3 | "version": "0.5.6", 4 | "description": "Schemas for the Jupyter interactive Widgets", 5 | "keywords": [ 6 | "jupyter", 7 | "schemas", 8 | "notebook" 9 | ], 10 | "homepage": "https://github.com/jupyter-widgets/ipywidgets#readme", 11 | "bugs": { 12 | "url": "https://github.com/jupyter-widgets/ipywidgets/issues" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/jupyter-widgets/ipywidgets.git" 17 | }, 18 | "license": "BSD-3-Clause", 19 | "author": "Project Jupyter", 20 | "main": "index.js", 21 | "scripts": { 22 | "test": "node index.js" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/schema/v1/view.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "description": "Jupyter Interactive Widget View JSON schema.", 4 | "type": "object", 5 | "properties": { 6 | "version_major": { 7 | "description": "Format version (major)", 8 | "type": "number", 9 | "minimum": 1, 10 | "maximum": 1 11 | }, 12 | "version_minor": { 13 | "description": "Format version (minor)", 14 | "type": "number" 15 | }, 16 | "model_id": { 17 | "description": "Unique identifier of the widget model to be displayed", 18 | "type": "string" 19 | } 20 | }, 21 | "required": ["model_id"], 22 | "additionalProperties": false 23 | } 24 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/view.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "description": "Jupyter Interactive Widget View JSON schema.", 4 | "type": "object", 5 | "properties": { 6 | "version_major": { 7 | "description": "Format version (major)", 8 | "type": "number", 9 | "minimum": 1, 10 | "maximum": 1 11 | }, 12 | "version_minor": { 13 | "description": "Format version (minor)", 14 | "type": "number" 15 | }, 16 | "model_id": { 17 | "description": "Unique identifier of the widget model to be displayed", 18 | "type": "string" 19 | }, 20 | "required": ["model_id"] 21 | }, 22 | "additionalProperties": false 23 | } 24 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/widget_core.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Base widget class for widgets provided in Core""" 5 | 6 | from .widget import Widget 7 | from .._version import __jupyter_widgets_controls_version__ 8 | 9 | from traitlets import Unicode 10 | 11 | class CoreWidget(Widget): 12 | 13 | _model_module = Unicode('@jupyter-widgets/controls').tag(sync=True) 14 | _model_module_version = Unicode(__jupyter_widgets_controls_version__).tag(sync=True) 15 | _view_module = Unicode('@jupyter-widgets/controls').tag(sync=True) 16 | _view_module_version = Unicode(__jupyter_widgets_controls_version__).tag(sync=True) 17 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/jupyterlab_widgets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from ._version import __version__ 5 | 6 | 7 | def _jupyter_labextension_paths(): 8 | import sys 9 | from pathlib import Path 10 | 11 | labext_name = '@jupyter-widgets/jupyterlab-manager' 12 | here = Path(__file__).parent.resolve() 13 | src_prefix = here.parent / 'labextension' 14 | 15 | if not src_prefix.exists(): 16 | src_prefix = Path(sys.prefix) / f'share/jupyter/labextensions/{labext_name}' 17 | 18 | return [{'src': str(src_prefix), 'dest': labext_name}] 19 | 20 | __all__ = ['_jupyter_labextension_paths', '__version__'] 21 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/docutils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | def doc_subst(snippets): 5 | """ Substitute format strings in class or function docstring """ 6 | def decorator(cls): 7 | # Running python with -OO will discard docstrings (__doc__ is None). 8 | if cls.__doc__ is not None: 9 | # Strip the snippets to avoid trailing new lines and whitespace 10 | stripped_snippets = { 11 | key: snippet.strip() for (key, snippet) in snippets.items() 12 | } 13 | cls.__doc__ = cls.__doc__.format(**stripped_snippets) 14 | return cls 15 | return decorator 16 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_widget_float.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from unittest import TestCase 5 | 6 | from traitlets import TraitError 7 | 8 | from ipywidgets import FloatSlider 9 | 10 | 11 | class TestFloatSlider(TestCase): 12 | 13 | def test_construction(self): 14 | FloatSlider() 15 | 16 | def test_construction_readout_format(self): 17 | slider = FloatSlider(readout_format='$.1f') 18 | assert slider.get_state()['readout_format'] == '$.1f' 19 | 20 | def test_construction_invalid_readout_format(self): 21 | with self.assertRaises(TraitError): 22 | FloatSlider(readout_format='broken') 23 | -------------------------------------------------------------------------------- /examples/web4/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/example-web4", 3 | "version": "8.0.14", 4 | "private": true, 5 | "description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.", 6 | "license": "BSD-3-Clause", 7 | "author": "IPython", 8 | "main": "index.js", 9 | "scripts": { 10 | "build": "webpack", 11 | "clean": "rimraf built", 12 | "test": "npm run test:default", 13 | "test:default": "echo \"No test specified\"" 14 | }, 15 | "dependencies": { 16 | "@jupyter-widgets/html-manager": "^1.0.14", 17 | "font-awesome": "^4.7.0" 18 | }, 19 | "devDependencies": { 20 | "css-loader": "^6.5.1", 21 | "style-loader": "^3.3.1", 22 | "webpack": "^5.65.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tsconfigbase.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/tsconfig", 3 | "compilerOptions": { 4 | "allowSyntheticDefaultImports": true, 5 | "composite": true, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "esModuleInterop": true, 9 | "incremental": true, 10 | "jsx": "react", 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "noEmitOnError": true, 14 | "noImplicitAny": true, 15 | "noImplicitThis": false, 16 | "noUnusedLocals": true, 17 | "preserveWatchOutput": true, 18 | "resolveJsonModule": true, 19 | "skipLibCheck": true, 20 | "sourceMap": true, 21 | "strict": true, 22 | "strictPropertyInitialization": false, 23 | "target": "es2017" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom_widget_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom Widget 3 | about: Issues or questions related to developing a custom widget 4 | labels: 'Custom Widget' 5 | --- 6 | 7 | 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | # PR limit is set to zero to get only security updates 8 | # Ref https://github.com/dependabot/dependabot-core/issues/2521#issuecomment-863261500 9 | updates: 10 | - package-ecosystem: npm 11 | directory: '/' 12 | schedule: 13 | interval: 'daily' 14 | open-pull-requests-limit: 0 # in case you don't want to enable version updates 15 | allow: 16 | - dependency-type: 'production' 17 | -------------------------------------------------------------------------------- /docs/source/ipywidgets_docs_utils.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def jupyterlab_markdown_heading(heading_text): 4 | """Use JupyterLab-style anchors for a consistent authoring/viewing experience. 5 | 6 | This _must_ be defined in an external file as local functions can't be asssigned 7 | to config values, as they can't be pickled. 8 | """ 9 | return heading_text.replace(" ", "-") 10 | 11 | def run_if_needed(args, cwd, skip_if=None): 12 | print(f"in {cwd}...") 13 | if skip_if: 14 | print("... skipping if found:", "\n".join(list(map(str, skip_if)))) 15 | if all(s.exists() for s in skip_if): 16 | print("...skipping") 17 | return 18 | print(">>>", " ".join(args)) 19 | subprocess.check_call(args, cwd=str(cwd)) 20 | -------------------------------------------------------------------------------- /python/widgetsnbextension/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | module.exports = { 3 | entry: ['./amd-public-path.js', './src/extension.js'], 4 | output: { 5 | filename: 'extension.js', 6 | path: path.resolve(__dirname, 'widgetsnbextension', 'static'), 7 | libraryTarget: 'amd', 8 | publicPath: '', // Set in amd-public-path.js 9 | }, 10 | devtool: 'source-map', 11 | module: { 12 | rules: [ 13 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 14 | // required to load font-awesome 15 | { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' }, 16 | { test: /\.svg$/i, type: 'asset' }, 17 | ], 18 | }, 19 | // 'module' is the magic requirejs dependency used to set the publicPath 20 | externals: ['module'], 21 | }; 22 | -------------------------------------------------------------------------------- /docs/source/reference/jupyter-widgets.md: -------------------------------------------------------------------------------- 1 | # `@jupyter-widgets` 2 | 3 | ## Packages 4 | 5 | - @jupyter-widgets/base 6 | - @jupyter-widgets/base-manager 7 | - @jupyter-widgets/controls 8 | - @jupyter-widgets/html-manager 9 | - @jupyter-widgets/jupyterlab-manager 10 | - @jupyter-widgets/output 11 | -------------------------------------------------------------------------------- /tsconfig.typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/tsconfig", 3 | "compilerOptions": { 4 | "lib": ["ES2019", "WebWorker", "ScriptHost", "DOM", "DOM.Iterable"], 5 | "paths": { 6 | "@jupyter-widgets/*": [ 7 | "./packages/*/src", 8 | "./python/jupyterlab_widgets/src" 9 | ] 10 | } 11 | }, 12 | "extends": "./tsconfigbase", 13 | "references": [ 14 | { 15 | "path": "./packages/base" 16 | }, 17 | { 18 | "path": "./packages/base-manager" 19 | }, 20 | { 21 | "path": "./packages/controls" 22 | }, 23 | { 24 | "path": "./packages/html-manager" 25 | }, 26 | { 27 | "path": "./packages/output" 28 | }, 29 | { 30 | "path": "./python/jupyterlab_widgets" 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /docs/Readme.md: -------------------------------------------------------------------------------- 1 | # Building ipywidgets documentation 2 | 3 | To build the ipywidgets documentation: 4 | 5 | 1. Install the development version of ipywidgets with the `dev-install.sh` script in the repo root directory. 6 | 2. Install the Python packages for building documentation with either mamba or conda: 7 | 8 | ```sh 9 | conda env update --file docs/environment.yml 10 | ``` 11 | 12 | or with `pip`: 13 | 14 | ```sh 15 | python -m pip install -r docs/requirements.txt 16 | # Also install pandoc separately 17 | ``` 18 | 19 | 3. Build the HTML docs with sphinx: 20 | 21 | ```sh 22 | cd docs/source 23 | python -m sphinx -T -E -b html -d ../build/doctrees -D language=en . ../build/html 24 | ``` 25 | 26 | 4. Open the documentation from the build directory: `docs/build/html` 27 | -------------------------------------------------------------------------------- /examples/web3/webpack.config.js: -------------------------------------------------------------------------------- 1 | const postcss = require('postcss'); 2 | var path = require('path'); 3 | const webpack = require('webpack'); 4 | 5 | module.exports = { 6 | mode: 'development', 7 | devtool: 'source-map', 8 | entry: './lib/index.js', 9 | output: { 10 | filename: 'index.built.js', 11 | path: path.resolve(__dirname, 'built'), 12 | }, 13 | module: { 14 | rules: [ 15 | { test: /\.css$/i, use: ['style-loader', 'css-loader'] }, 16 | // required to load font-awesome 17 | { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' }, 18 | { test: /\.svg$/i, type: 'asset' }, 19 | ], 20 | }, 21 | plugins: [ 22 | new webpack.DefinePlugin({ 23 | process: { 24 | cwd: () => '/', 25 | env: {}, 26 | }, 27 | }), 28 | ], 29 | }; 30 | -------------------------------------------------------------------------------- /ui-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/ui-tests", 3 | "private": true, 4 | "version": "0.1.0", 5 | "description": "ipywidgets UI Tests", 6 | "scripts": { 7 | "start": "jupyter lab --config ./jupyter_server_config.py", 8 | "start:detached": "jlpm start&", 9 | "test": "npx playwright test", 10 | "test:debug": "PWDEBUG=1 npx playwright test", 11 | "test:report": "http-server ./playwright-report -a localhost -o", 12 | "test:update": "npx playwright test --update-snapshots", 13 | "deduplicate": "jlpm && yarn-deduplicate -s fewer --fail" 14 | }, 15 | "author": "Project Jupyter", 16 | "license": "BSD-3-Clause", 17 | "devDependencies": { 18 | "@jupyterlab/galata": "^5.3.4", 19 | "@playwright/test": "^1.32.0", 20 | "yarn-deduplicate": "^6.0.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_docutils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from unittest import TestCase 5 | 6 | from ipywidgets.widgets.docutils import doc_subst 7 | 8 | 9 | class TestDocSubst(TestCase): 10 | 11 | def test_substitution(self): 12 | snippets = {'key': '62'} 13 | 14 | @doc_subst(snippets) 15 | def f(): 16 | """ Docstring with value {key} """ 17 | 18 | assert "Docstring with value 62" in f.__doc__ 19 | 20 | def test_unused_keys(self): 21 | snippets = {'key': '62', 'other-key': 'unused'} 22 | 23 | @doc_subst(snippets) 24 | def f(): 25 | """ Docstring with value {key} """ 26 | 27 | assert "Docstring with value 62" in f.__doc__ 28 | -------------------------------------------------------------------------------- /docs/environment.yml: -------------------------------------------------------------------------------- 1 | name: ipywidgets_docs 2 | channels: 3 | - conda-forge 4 | - nodefaults 5 | dependencies: 6 | - python >=3.11,<3.12 7 | # build 8 | - python-build 9 | - pip 10 | - packaging 11 | - jupyter-packaging 12 | - jupyterlab >=4,<5 13 | - nodejs >=18,<19 14 | # dependencies 15 | - jupyter_client 16 | # docs 17 | - docutils >=0.19 18 | - jupyterlab-myst 19 | - myst-nb >=0.17,<0.18 20 | - pandoc 21 | - pydata-sphinx-theme 22 | - sphinx >=5,<6 23 | - sphinx-autobuild 24 | - sphinx-autodoc-typehints 25 | - sphinx-copybutton 26 | - sphinxext-rediraffe 27 | # demo 28 | - bqplot 29 | - ipykernel 30 | - ipyleaflet 31 | - jupyterlite-core >=0.3.0,<0.4.0 32 | - jupyterlite-pyodide-kernel 33 | - matplotlib-base 34 | - numpy 35 | - scikit-image 36 | - scikit-learn 37 | - sympy 38 | -------------------------------------------------------------------------------- /packages/base/test/webpack-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'coverage.js', 8 | }, 9 | bail: true, 10 | module: { 11 | loaders: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | preLoaders: [ 22 | // instrument only testing sources with Istanbul 23 | { 24 | test: /\.js$/, 25 | include: path.resolve('lib/'), 26 | loader: 'istanbul-instrumenter', 27 | }, 28 | ], 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /packages/base-manager/test/webpack-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'coverage.js', 8 | }, 9 | bail: true, 10 | module: { 11 | loaders: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | preLoaders: [ 22 | // instrument only testing sources with Istanbul 23 | { 24 | test: /\.js$/, 25 | include: path.resolve('lib/'), 26 | loader: 'istanbul-instrumenter', 27 | }, 28 | ], 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /packages/controls/test/webpack-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + '/build', 7 | filename: 'coverage.js', 8 | }, 9 | bail: true, 10 | module: { 11 | loaders: [ 12 | { test: /\.css$/, use: ['style-loader', 'css-loader'] }, 13 | { test: /\.md$/, type: 'asset/source' }, 14 | { 15 | test: /\.html$/, 16 | type: 'asset/resource', 17 | generator: { filename: '[name].[ext]' }, 18 | }, 19 | { test: /\.ipynb$/, type: 'json' }, 20 | ], 21 | preLoaders: [ 22 | // instrument only testing sources with Istanbul 23 | { 24 | test: /\.js$/, 25 | include: path.resolve('lib/'), 26 | loader: 'istanbul-instrumenter', 27 | }, 28 | ], 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /docs/source/how-to/index.md: -------------------------------------------------------------------------------- 1 | # How-to Guides 2 | 3 | ```{toctree} 4 | :caption: Using Widgets 5 | :maxdepth: 1 6 | ../examples 7 | ../user_install 8 | ../examples/Widget Basics 9 | ../examples/Widget List 10 | ../examples/Output Widget 11 | ../examples/Widget Events 12 | ../examples/Widget Styling 13 | ../examples/Widget Layout 14 | ../examples/Layout Templates 15 | ../examples/Using Interact 16 | ../examples/Widget Asynchronous 17 | ``` 18 | 19 | ```{toctree} 20 | :caption: Upgrading 21 | :maxdepth: 1 22 | ../user_migration_guides 23 | ../migration_guides 24 | ``` 25 | 26 | ```{toctree} 27 | :caption: Publishing Content with Widgets 28 | :maxdepth: 1 29 | ../embedding 30 | ``` 31 | 32 | ```{toctree} 33 | :caption: Contributing to Jupyter Widgets 34 | :maxdepth: 1 35 | ../dev_install 36 | ../dev_testing 37 | ../dev_docs 38 | ../contributing 39 | ../dev_release 40 | ``` 41 | -------------------------------------------------------------------------------- /examples/web2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/example-web2", 3 | "version": "8.0.13", 4 | "private": true, 5 | "description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.", 6 | "license": "BSD-3-Clause", 7 | "author": "IPython", 8 | "main": "index.js", 9 | "scripts": { 10 | "build": "webpack", 11 | "clean": "rimraf built", 12 | "test": "npm run test:default", 13 | "test:default": "echo \"No test specified\"" 14 | }, 15 | "dependencies": { 16 | "@jupyter-widgets/base": "^6.0.11", 17 | "@jupyter-widgets/base-manager": "^1.0.12", 18 | "@jupyter-widgets/controls": "^5.0.12", 19 | "codemirror": "^5.48.0", 20 | "font-awesome": "^4.7.0" 21 | }, 22 | "devDependencies": { 23 | "css-loader": "^6.5.1", 24 | "style-loader": "^3.3.1", 25 | "webpack": "^5.65.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | MANIFEST 2 | build 3 | dist 4 | _build 5 | docs/man/*.gz 6 | docs/source/api/generated 7 | docs/source/.cache 8 | *.doit.db 9 | _contents 10 | node_modules 11 | *.py[co] 12 | __pycache__ 13 | *.egg-info 14 | *~ 15 | *.bak 16 | .ipynb_checkpoints 17 | .tox 18 | .DS_Store 19 | \#*# 20 | .#* 21 | .coverage 22 | .xunit.xml 23 | .tern-project 24 | npm-debug.log 25 | .pytest_cache 26 | .vscode/* 27 | !.vscode/extensions.json 28 | 29 | # Generated files 30 | python/widgetsnbextension/widgetsnbextension/static 31 | python/jupyterlab_widgets/labextension/ 32 | packages/controls/css/nouislider.css 33 | 34 | index.built.js 35 | index.built.js.map 36 | **/es5/ 37 | 38 | **/built 39 | **/lib/ 40 | 41 | temp/* 42 | 43 | *.tsbuildinfo 44 | 45 | ui-tests/test-results 46 | ui-tests/playwright-report 47 | 48 | **/lite/_output/ 49 | **/lite/.cache 50 | **/*.doit.* 51 | **/docs/typedoc/ 52 | 53 | .yarn 54 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_send_state.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from traitlets import Bool, Tuple, List 5 | 6 | from .utils import setup 7 | 8 | from ..widget import Widget 9 | 10 | from ..._version import __control_protocol_version__ 11 | 12 | # A widget with simple traits 13 | class SimpleWidget(Widget): 14 | a = Bool().tag(sync=True) 15 | b = Tuple(Bool(), Bool(), Bool(), default_value=(False, False, False)).tag( 16 | sync=True 17 | ) 18 | c = List(Bool()).tag(sync=True) 19 | 20 | 21 | def test_empty_send_state(): 22 | w = SimpleWidget() 23 | w.send_state([]) 24 | assert w.comm.messages == [] 25 | 26 | 27 | def test_empty_hold_sync(): 28 | w = SimpleWidget() 29 | with w.hold_sync(): 30 | pass 31 | assert w.comm.messages == [] 32 | -------------------------------------------------------------------------------- /.github/workflows/answered.yml: -------------------------------------------------------------------------------- 1 | # This action automatically schedules issues to be closed that have been 2 | # labeled as answered if there is no activity on them for 30 days. This takes 3 | # care of the common usecase of an issue being answered to the best of our 4 | # ability and no other follow-up from the submitter. 5 | name: 'Close answered issues' 6 | on: 7 | schedule: 8 | - cron: '30 1 * * *' 9 | 10 | permissions: 11 | issues: write 12 | 13 | jobs: 14 | stale: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/stale@v3 18 | with: 19 | days-before-pr-stale: -1 20 | days-before-pr-close: -1 21 | skip-stale-issue-message: true 22 | days-before-issue-stale: 30 23 | days-before-issue-close: 7 24 | stale-issue-label: 'closing as answered' 25 | stale-issue-message: '.' 26 | only-issue-labels: 'answered' 27 | -------------------------------------------------------------------------------- /python/widgetsnbextension/widgetsnbextension/__init__.py: -------------------------------------------------------------------------------- 1 | """Interactive widgets for the Jupyter notebook. 2 | 3 | Provide simple interactive controls in the notebook. 4 | Each widget corresponds to an object in Python and Javascript, 5 | with controls on the page. 6 | 7 | You can display widgets with IPython's display machinery:: 8 | 9 | from ipywidgets import IntSlider 10 | from IPython.display import display 11 | slider = IntSlider(min=1, max=10) 12 | display(slider) 13 | 14 | Moving the slider will change the value. Most widgets have a current value, 15 | accessible as a `value` attribute. 16 | """ 17 | from ._version import __version__ 18 | from warnings import warn 19 | 20 | def _jupyter_nbextension_paths(): 21 | return [{ 22 | 'section': 'notebook', 23 | 'src': 'static', 24 | 'dest': 'jupyter-js-widgets', 25 | 'require': 'jupyter-js-widgets/extension' 26 | }] 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation improvement 3 | about: Create a report to help us improve the documentation 4 | labels: docs 5 | --- 6 | 7 | 8 | 9 | 10 | ### Problem 11 | 12 | 19 | 20 | ### Suggested Improvement 21 | 22 | 29 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | enableImmutableInstalls: false 3 | 4 | # prettier-ignore 5 | packageExtensions: 6 | "@nrwl/devkit@^15": 7 | dependencies: 8 | nx: ^15 9 | postcss-cssnext@^3.1.0: 10 | dependencies: 11 | caniuse-lite: ^1 12 | source-map-loader@^4: 13 | dependencies: 14 | webpack: ^5 15 | 16 | enableTelemetry: false 17 | 18 | httpTimeout: 60000 19 | 20 | # these messages provide no actionable information, and make non-TTY output 21 | # almost unreadable, masking real dependency-related information 22 | # see: https://yarnpkg.com/advanced/error-codes 23 | logFilters: 24 | - code: YN0006 # SOFT_LINK_BUILD 25 | level: discard 26 | - code: YN0007 # MUST_BUILD 27 | level: discard 28 | - code: YN0008 # MUST_REBUILD 29 | level: discard 30 | - code: YN0013 # FETCH_NOT_CACHED 31 | level: discard 32 | - code: YN0019 # UNUSED_CACHE_ENTRY 33 | level: discard 34 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/comm.py: -------------------------------------------------------------------------------- 1 | # compatibility shim for ipykernel < 6.18 2 | import sys 3 | from IPython import get_ipython 4 | import comm 5 | 6 | 7 | def requires_ipykernel_shim(): 8 | if "ipykernel" in sys.modules: 9 | import ipykernel 10 | 11 | version = ipykernel.version_info 12 | return version < (6, 18) 13 | else: 14 | return False 15 | 16 | 17 | def get_comm_manager(): 18 | if requires_ipykernel_shim(): 19 | ip = get_ipython() 20 | 21 | if ip is not None and getattr(ip, "kernel", None) is not None: 22 | return get_ipython().kernel.comm_manager 23 | else: 24 | return comm.get_comm_manager() 25 | 26 | 27 | def create_comm(*args, **kwargs): 28 | if requires_ipykernel_shim(): 29 | from ipykernel.comm import Comm 30 | 31 | return Comm(*args, **kwargs) 32 | else: 33 | return comm.create_comm(*args, **kwargs) 34 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/widget_color.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Color class. 5 | 6 | Represents an HTML Color . 7 | """ 8 | 9 | from .widget_description import DescriptionWidget 10 | from .valuewidget import ValueWidget 11 | from .widget import register 12 | from .widget_core import CoreWidget 13 | from .trait_types import Color 14 | from traitlets import Unicode, Bool 15 | 16 | 17 | @register 18 | class ColorPicker(DescriptionWidget, ValueWidget, CoreWidget): 19 | value = Color('black', help="The color value.").tag(sync=True) 20 | concise = Bool(help="Display short version with just a color selector.").tag(sync=True) 21 | disabled = Bool(False, help="Enable or disable user changes.").tag(sync=True) 22 | 23 | _view_name = Unicode('ColorPickerView').tag(sync=True) 24 | _model_name = Unicode('ColorPickerModel').tag(sync=True) 25 | -------------------------------------------------------------------------------- /examples/embed-amd/README.md: -------------------------------------------------------------------------------- 1 | # Using the HTML widget manager as a RequireJS AMD module 2 | 3 | ## Description 4 | 5 | This is an example project showing how to embed widgets in an HTML document using a RequireJS AMD module. 6 | 7 | In order to test the current development repo, make a symbolic link from the `packages/html-manager` directory to this directory and uncomment the `html-manager` paths config in `index.html`. 8 | 9 | The widget data in this example was generated from the following code: 10 | 11 | ```python 12 | from ipywidgets import VBox, jsdlink, IntSlider, Button 13 | 14 | s1, s2 = IntSlider(max=200, value=100), IntSlider(value=40) 15 | b = Button(icon='legal') 16 | jsdlink((s1, 'value'), (s2, 'max')) 17 | VBox([s1, s2, b]) 18 | ``` 19 | 20 | ## Try it 21 | 22 | 1. Start with a repository checkout, and run `yarn install` in the root directory. 23 | 2. Run `yarn build:examples` in the root directory. 24 | 3. Open the `index.html` file in this directory. 25 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/valuewidget.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Contains the ValueWidget class""" 5 | 6 | from .widget import Widget 7 | from traitlets import Any 8 | 9 | 10 | class ValueWidget(Widget): 11 | """Widget that can be used for the input of an interactive function""" 12 | 13 | value = Any(help="The value of the widget.") 14 | 15 | def get_interact_value(self): 16 | """Return the value for this widget which should be passed to 17 | interactive functions. Custom widgets can change this method 18 | to process the raw value ``self.value``. 19 | """ 20 | return self.value 21 | 22 | def _repr_keys(self): 23 | # Ensure value key comes first, and is always present 24 | yield 'value' 25 | for key in super()._repr_keys(): 26 | if key != 'value': 27 | yield key 28 | -------------------------------------------------------------------------------- /python/ipywidgets/README.md: -------------------------------------------------------------------------------- 1 | # ipywidgets: Interactive HTML Widgets 2 | 3 | **ipywidgets**, also known as jupyter-widgets or simply widgets, are 4 | [interactive HTML widgets](https://github.com/jupyter-widgets/ipywidgets/blob/main/docs/source/examples/Index.ipynb) 5 | for Jupyter notebooks and the IPython kernel. 6 | 7 | This package contains the python implementation of the core interactive widgets bundled in ipywidgets. 8 | 9 | ## Core Interactive Widgets 10 | 11 | The fundamental widgets provided by this library are called core interactive 12 | widgets. A [demonstration notebook](https://github.com/jupyter-widgets/ipywidgets/blob/main/docs/source/examples/Index.ipynb) 13 | provides an overview of the core interactive widgets, including: 14 | 15 | - sliders 16 | - progress bars 17 | - text boxes 18 | - toggle buttons and checkboxes 19 | - display areas 20 | - and more 21 | 22 | For more information, see the main [documentation](https://github.com/jupyter-widgets/ipywidgets#readme). 23 | -------------------------------------------------------------------------------- /packages/controls/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export * from './utils'; 5 | export * from './version'; 6 | export * from './widget_link'; 7 | export * from './widget_bool'; 8 | export * from './widget_button'; 9 | export * from './widget_box'; 10 | export * from './widget_image'; 11 | export * from './widget_video'; 12 | export * from './widget_audio'; 13 | export * from './widget_color'; 14 | export * from './widget_date'; 15 | export * from './widget_datetime'; 16 | export * from './widget_time'; 17 | export * from './widget_int'; 18 | export * from './widget_float'; 19 | export * from './widget_controller'; 20 | export * from './widget_selection'; 21 | export * from './widget_selectioncontainer'; 22 | export * from './widget_tagsinput'; 23 | export * from './widget_string'; 24 | export * from './widget_description'; 25 | export * from './widget_upload'; 26 | 27 | export const version = (require('../package.json') as any).version; 28 | -------------------------------------------------------------------------------- /python/widgetsnbextension/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) IPython Development Team. 4 | # Copyright (c) Jupyter Development Team. 5 | # Distributed under the terms of the Modified BSD License. 6 | 7 | from jupyter_packaging import ( 8 | wrap_installers, 9 | npm_builder, 10 | get_data_files 11 | ) 12 | from pathlib import Path 13 | from setuptools import setup 14 | 15 | HERE = Path(__file__).parent.resolve() 16 | IS_REPO = (HERE.parent / '.git').exists() 17 | JS_DIR = HERE / 'src' 18 | 19 | data_files_spec = [( 20 | 'share/jupyter/nbextensions/jupyter-js-widgets', 'widgetsnbextension/static', 'extension.js*'), 21 | ('etc/jupyter/nbconfig/notebook.d' , '.', 'widgetsnbextension.json') 22 | ] 23 | 24 | post_develop = npm_builder( 25 | build_cmd="yarn", source_dir="src", build_dir=JS_DIR 26 | ) 27 | 28 | cmdclass = wrap_installers(post_develop=post_develop) 29 | 30 | if __name__ == '__main__': 31 | setup( 32 | cmdclass=cmdclass, 33 | data_files=get_data_files(data_files_spec), 34 | ) 35 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:@typescript-eslint/eslint-recommended", 6 | "plugin:@typescript-eslint/recommended", 7 | "prettier" 8 | ], 9 | "rules": { 10 | "@typescript-eslint/naming-convention": [ 11 | "error", 12 | { 13 | "selector": "interface", 14 | "format": ["PascalCase"], 15 | "custom": { 16 | "regex": "^I[A-Z]", 17 | "match": true 18 | } 19 | } 20 | ], 21 | "@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }], 22 | "@typescript-eslint/no-use-before-define": "off", 23 | "@typescript-eslint/no-explicit-any": "off", 24 | "@typescript-eslint/no-non-null-assertion": "off", 25 | "@typescript-eslint/no-namespace": "off", 26 | "@typescript-eslint/no-var-requires": "off", 27 | "@typescript-eslint/ban-types": "off", 28 | "@typescript-eslint/camelcase": "off" 29 | }, 30 | "parser": "@typescript-eslint/parser", 31 | "plugins": ["@typescript-eslint"] 32 | } 33 | -------------------------------------------------------------------------------- /packages/output/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/output", 3 | "version": "6.0.11", 4 | "description": "Jupyter widget wrapping cell output", 5 | "bugs": { 6 | "url": "https://github.com/jupyter-widgets/ipywidgets/issues" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/jupyter-widgets/ipywidgets.git" 11 | }, 12 | "license": "BSD-3-Clause", 13 | "author": "Project Jupyter", 14 | "main": "lib/index.js", 15 | "typings": "lib/index.d.ts", 16 | "files": [ 17 | "lib/**/*.map", 18 | "lib/**/*.d.ts", 19 | "lib/**/*.js", 20 | "src" 21 | ], 22 | "scripts": { 23 | "build": "npm run build:src", 24 | "build:src": "tsc --build", 25 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", 26 | "prepublish": "npm run clean && npm run build", 27 | "test": "echo \"Error: no test specified\" && exit 1" 28 | }, 29 | "dependencies": { 30 | "@jupyter-widgets/base": "^6.0.11" 31 | }, 32 | "devDependencies": { 33 | "rimraf": "^3.0.2", 34 | "typescript": "~4.9.4" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/html-manager/scripts/concat-amd-build.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | var fs = require('fs'); 5 | 6 | // Make a script file that defines all of the relevant AMD modules 7 | var files = [ 8 | 'base.js', 9 | 'controls.js', 10 | 'base7.js', 11 | 'controls7.js', 12 | 'index.js', 13 | 'libembed-amd.js', 14 | ]; 15 | var output = files 16 | .map((f) => { 17 | return fs.readFileSync('./dist/amd/' + f).toString(); 18 | }) 19 | .join(';\n\n'); 20 | fs.writeFileSync('./dist/libembed-amd.js', output); 21 | 22 | // Make a script that has all of the above AMD modules and runs a function which 23 | // renders all of the widgets on page load automatically. 24 | files = [ 25 | 'base.js', 26 | 'controls.js', 27 | 'base7.js', 28 | 'controls7.js', 29 | 'index.js', 30 | 'libembed-amd.js', 31 | 'embed-amd-render.js', 32 | ]; 33 | var output = files 34 | .map((f) => { 35 | return fs.readFileSync('./dist/amd/' + f).toString(); 36 | }) 37 | .join(';\n\n'); 38 | fs.writeFileSync('./dist/embed-amd.js', output); 39 | -------------------------------------------------------------------------------- /examples/web3/README.md: -------------------------------------------------------------------------------- 1 | # Using jupyter-js-widgets in non-notebook, web context 2 | 3 | ## Description 4 | 5 | This directory is an example project that shows how to use Jupyter widgets 6 | in a web context other than the notebook. 7 | 8 | This example requires a Jupyter notebook server to be running. The user is 9 | prompted with a dialog to provide the URL with a running notebook server. 10 | 11 | This example also displays read-only text area containing the code 12 | provided in the `widget_code.json`, which we used to generate the widget state. 13 | 14 | ## Try it 15 | 16 | 1. Start with a repository checkout, and run `yarn install` in the root directory. 17 | 2. Run `yarn build:examples` in the root directory. 18 | 3. Change to this directory 19 | 4. Run `yarn host` 20 | 5. In a new terminal run `python -m notebook --no-browser --NotebookApp.allow_origin="*" --NotebookApp.disable_check_xsrf=True --NotebookApp.token=''`. **WARNING: This starts an insecure Jupyter notebook server. Do not do this in production.** 21 | 6. In a web browser, navigate to `http://localhost:8080/` (or the address specified by the `yarn host` command) 22 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_link.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | import pytest 5 | 6 | from .. import jslink, jsdlink, ToggleButton 7 | 8 | def test_jslink_args(): 9 | with pytest.raises(TypeError): 10 | jslink() 11 | w1 = ToggleButton() 12 | with pytest.raises(TypeError): 13 | jslink((w1, 'value')) 14 | 15 | w2 = ToggleButton() 16 | jslink((w1, 'value'), (w2, 'value')) 17 | 18 | with pytest.raises(TypeError): 19 | jslink((w1, 'value'), (w2, 'nosuchtrait')) 20 | 21 | with pytest.raises(TypeError): 22 | jslink((w1, 'value'), (w2, 'traits')) 23 | 24 | def test_jsdlink_args(): 25 | with pytest.raises(TypeError): 26 | jsdlink() 27 | w1 = ToggleButton() 28 | with pytest.raises(TypeError): 29 | jsdlink((w1, 'value')) 30 | 31 | w2 = ToggleButton() 32 | jsdlink((w1, 'value'), (w2, 'value')) 33 | 34 | with pytest.raises(TypeError): 35 | jsdlink((w1, 'value'), (w2, 'nosuchtrait')) 36 | 37 | with pytest.raises(TypeError): 38 | jsdlink((w1, 'value'), (w2, 'traits')) 39 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_widget_box.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from unittest import TestCase 5 | 6 | from traitlets import TraitError 7 | 8 | import ipywidgets as widgets 9 | 10 | 11 | class TestBox(TestCase): 12 | 13 | def test_construction(self): 14 | box = widgets.Box() 15 | assert box.get_state()['children'] == [] 16 | 17 | def test_construction_with_children(self): 18 | html = widgets.HTML('some html') 19 | slider = widgets.IntSlider() 20 | box = widgets.Box([html, slider]) 21 | children_state = box.get_state()['children'] 22 | assert children_state == [ 23 | widgets.widget._widget_to_json(html, None), 24 | widgets.widget._widget_to_json(slider, None), 25 | ] 26 | 27 | def test_construction_style(self): 28 | box = widgets.Box(box_style='warning') 29 | assert box.get_state()['box_style'] == 'warning' 30 | 31 | def test_construction_invalid_style(self): 32 | with self.assertRaises(TraitError): 33 | widgets.Box(box_style='invalid') 34 | -------------------------------------------------------------------------------- /packages/base/css/index.css: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Jupyter Development Team. 2 | * Distributed under the terms of the Modified BSD License. 3 | */ 4 | 5 | .jupyter-widgets-disconnected::before { 6 | content: '\f127'; /* chain-broken */ 7 | display: inline-block; 8 | font: normal normal 900 14px/1 'Font Awesome 5 Free', 'FontAwesome'; 9 | text-rendering: auto; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | color: #d9534f; 13 | padding: 3px; 14 | align-self: flex-start; 15 | } 16 | 17 | .jupyter-widgets-error-widget { 18 | display: flex; 19 | flex-direction: column; 20 | justify-content: center; 21 | height: 100%; 22 | border: solid 1px red; 23 | margin: 0 auto; 24 | } 25 | 26 | .jupyter-widgets-error-widget.icon-error { 27 | min-width: var(--jp-widgets-inline-width-short); 28 | } 29 | .jupyter-widgets-error-widget.text-error { 30 | min-width: calc(2 * var(--jp-widgets-inline-width)); 31 | min-height: calc(3 * var(--jp-widgets-inline-height)); 32 | } 33 | 34 | .jupyter-widgets-error-widget p { 35 | text-align: center; 36 | } 37 | 38 | .jupyter-widgets-error-widget.text-error pre::first-line { 39 | font-weight: bold; 40 | } 41 | -------------------------------------------------------------------------------- /examples/web2/index.js: -------------------------------------------------------------------------------- 1 | var CodeMirror = require('codemirror'); 2 | require('codemirror/lib/codemirror.css'); 3 | require('codemirror/mode/python/python'); 4 | var WidgetManager = require('./manager').WidgetManager; 5 | 6 | require('@jupyter-widgets/controls/css/widgets.css'); 7 | require('font-awesome/css/font-awesome.css'); 8 | 9 | document.addEventListener('DOMContentLoaded', function (event) { 10 | var code = require('./widget_code.py'); 11 | var inputarea = document.getElementsByClassName('inputarea')[0]; 12 | new CodeMirror(inputarea, { 13 | value: code, 14 | mode: 'python', 15 | tabSize: 4, 16 | showCursorWhenSelecting: true, 17 | viewportMargin: Infinity, 18 | readOnly: true, 19 | }); 20 | 21 | var state = require('./widget_state.json'); 22 | var widgetarea = document.getElementsByClassName('widgetarea')[0]; 23 | var manager = new WidgetManager(widgetarea); 24 | manager 25 | .set_state(state) 26 | .then((models) => 27 | manager.create_view( 28 | models.find( 29 | (element) => element.model_id == '8621699ecc804983a612f09b7dfe806b' 30 | ) 31 | ) 32 | ) 33 | .then((view) => manager.display_view(view)); 34 | }); 35 | -------------------------------------------------------------------------------- /.github/workflows/devinstall.yml: -------------------------------------------------------------------------------- 1 | name: Run the dev-install script 2 | 3 | on: 4 | push: 5 | branches: main 6 | pull_request: 7 | branches: '*' 8 | 9 | jobs: 10 | devinstall: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v4 15 | - name: Install Python 16 | uses: actions/setup-python@v4 17 | with: 18 | python-version: '3.13' 19 | architecture: 'x64' 20 | - name: Cache pip on Linux 21 | uses: actions/cache@v3 22 | if: startsWith(runner.os, 'Linux') 23 | with: 24 | path: ~/.cache/pip 25 | key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('**/requirements.txt') }} 26 | restore-keys: | 27 | ${{ runner.os }}-pip-${{ matrix.python }} 28 | 29 | - name: Install dependencies 30 | run: | 31 | python -m pip install notebook jupyterlab notebook~=6.0 jupyter_packaging~=0.10 32 | - name: Run the dev-install script 33 | run: | 34 | ./dev-install.sh 35 | jupyter nbextension list 36 | jupyter labextension list 37 | 38 | python -m jupyterlab.browser_check 39 | -------------------------------------------------------------------------------- /docs/source/examples/images/flex-container.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | container 19 | 20 | -------------------------------------------------------------------------------- /examples/web1/test/index.js: -------------------------------------------------------------------------------- 1 | const widgetsRendered = new Promise((resolve, reject) => { 2 | setTimeout( 3 | () => reject(Error('timeout waiting for widgets to render')), 4 | 5000 5 | ); // 5s timeout 6 | 7 | const listener = () => { 8 | resolve(); 9 | document.removeEventListener('widgetsRendered', listener); 10 | }; 11 | document.addEventListener('widgetsRendered', listener); 12 | }); 13 | 14 | describe('index.html', function () { 15 | this.timeout(10000); 16 | 17 | beforeEach(() => { 18 | return widgetsRendered; 19 | }); 20 | 21 | describe('textArea', () => { 22 | it('exists', () => { 23 | expect(document.querySelector('textarea')).to.be.ok; 24 | }); 25 | it('correct value', () => { 26 | expect(document.querySelector('textarea').value).to.equal( 27 | 'test text' 28 | ); 29 | }); 30 | }); 31 | describe('html', () => { 32 | it('exists', () => { 33 | expect(document.querySelector('div.widget-html')).to.be.ok; 34 | }); 35 | it('correct value', () => { 36 | expect( 37 | document.querySelector('div.widget-html-content').innerHTML 38 | ).to.equal('test text'); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/src/semvercache.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { maxSatisfying } from 'semver'; 5 | 6 | /** 7 | * A cache using semver ranges to retrieve values. 8 | */ 9 | export class SemVerCache { 10 | set(key: string, version: string, object: T): void { 11 | if (!(key in this._cache)) { 12 | this._cache[key] = Object.create(null); 13 | } 14 | if (!(version in this._cache[key])) { 15 | this._cache[key][version] = object; 16 | } else { 17 | throw `Version ${version} of key ${key} already registered.`; 18 | } 19 | } 20 | 21 | get(key: string, semver: string): T | undefined { 22 | if (key in this._cache) { 23 | const versions = this._cache[key]; 24 | const best = maxSatisfying(Object.keys(versions), semver); 25 | if (best !== null) { 26 | return versions[best]; 27 | } 28 | } 29 | } 30 | 31 | getAllVersions(key: string): Object | undefined { 32 | if (key in this._cache) { 33 | return this._cache[key]; 34 | } 35 | } 36 | 37 | private _cache: { [key: string]: { [version: string]: T } } = 38 | Object.create(null); 39 | } 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest a way to improve ipywidgets 4 | labels: type:Enhancement 5 | --- 6 | 7 | 13 | 14 | ### Problem 15 | 16 | 21 | 22 | ### Proposed Solution 23 | 24 | 28 | 29 | ### Additional context 30 | 31 | 35 | -------------------------------------------------------------------------------- /examples/web2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 36 | 37 | 38 |
39 |
40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/web3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 36 | 37 | 38 |
39 |
40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/web3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/example-web3", 3 | "version": "8.0.14", 4 | "private": true, 5 | "description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.", 6 | "license": "BSD-3-Clause", 7 | "author": "IPython", 8 | "main": "lib/index.js", 9 | "scripts": { 10 | "build": "npm run clean && tsc && node scripts/copyfiles.js && webpack", 11 | "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo && rimraf built", 12 | "host": "http-server", 13 | "test": "npm run test:default", 14 | "test:default": "echo \"No test specified\"" 15 | }, 16 | "dependencies": { 17 | "@jupyter-widgets/base": "^6.0.11", 18 | "@jupyter-widgets/controls": "^5.0.12", 19 | "@jupyter-widgets/html-manager": "^1.0.14", 20 | "@jupyterlab/services": "^6.0.0 || ^7.0.0", 21 | "codemirror": "^5.48.0", 22 | "font-awesome": "^4.7.0", 23 | "http-server": "^14.0.0" 24 | }, 25 | "devDependencies": { 26 | "@types/codemirror": "^5.60.0", 27 | "@types/node": "^17.0.2", 28 | "css-loader": "^6.5.1", 29 | "fs-extra": "^10.0.0", 30 | "rimraf": "^3.0.2", 31 | "style-loader": "^3.3.1", 32 | "typescript": "~4.9.4", 33 | "webpack": "^5.65.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/controls/src/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | export { uuid, resolvePromisesDict } from '@jupyter-widgets/base'; 5 | 6 | /** 7 | * Apply MathJax rendering to an element, and optionally set its text. 8 | * 9 | * If MathJax is not available, make no changes. 10 | * 11 | * Parameters 12 | * ---------- 13 | * element: Node 14 | * text: optional string 15 | */ 16 | export function typeset(element: HTMLElement, text?: string): void { 17 | if (text !== void 0) { 18 | element.textContent = text; 19 | } 20 | if ((window as any).MathJax !== void 0) { 21 | MathJax!.Hub!.Queue(['Typeset', MathJax.Hub, element]); 22 | } 23 | } 24 | 25 | /** 26 | * escape text to HTML 27 | */ 28 | export function escape_html(text: string): string { 29 | const esc = document.createElement('div'); 30 | esc.textContent = text; 31 | return esc.innerHTML; 32 | } 33 | 34 | /** 35 | * Creates a wrappable Promise rejection function. 36 | */ 37 | export function reject(message: string, log: boolean) { 38 | return function promiseRejection(error: Error): never { 39 | if (log) { 40 | console.error(new Error(message)); 41 | } 42 | throw error; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/binder-on-pr.yml: -------------------------------------------------------------------------------- 1 | # Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html 2 | name: Binder Badge 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | 7 | permissions: 8 | pull-requests: write 9 | 10 | jobs: 11 | binder: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: comment on PR with Binder link 15 | uses: actions/github-script@v6 16 | with: 17 | github-token: ${{secrets.GITHUB_TOKEN}} 18 | script: | 19 | var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO; 20 | var PR_HEAD_REF = process.env.PR_HEAD_REF; 21 | github.rest.issues.createComment({ 22 | issue_number: context.issue.number, 23 | owner: context.repo.owner, 24 | repo: context.repo.repo, 25 | body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab/tree/docs/source/examples/) :point_left: Launch a binder notebook on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_` 26 | }) 27 | env: 28 | PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} 29 | PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }} 30 | -------------------------------------------------------------------------------- /examples/web2/README.md: -------------------------------------------------------------------------------- 1 | # Ad hoc widget manager reading a file with the `application/vnd.jupyter.widget-state+json` mime type. 2 | 3 | ## Description 4 | 5 | This directory is an example project that shows how to use the 6 | Jupyter widgets library in a pure JavaScript context. 7 | 8 | This example implements a simple widget manager 9 | by extending the base widget manager from the `@jupyter-widgets/base` library. This custom widget manager reads the state of the widget manager in the 10 | `widget_state.json` file, which respects the standardized JSON schema for the 11 | `application/vnd.jupyter.widget-state+json` mime type. Such a `widget_state.json` file can be generated from rendered widgets in the 12 | classic Jupyter Notebook with the _Download widget state_ action. 13 | 14 | This example also displays a read-only text area containing the code 15 | provided in the `widget_code.json`, which we used to generate the widget state. 16 | 17 | This example does not implement the communication with a Python backend. For 18 | such an example, check out the `web3` example. 19 | 20 | ## Try it 21 | 22 | 1. Start with a repository checkout, and run `yarn install` in the root directory. 23 | 2. Run `yarn build:examples` in the root directory. 24 | 3. Open the `index.html` file in this directory. 25 | -------------------------------------------------------------------------------- /examples/web1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/example-web1", 3 | "version": "8.0.13", 4 | "private": true, 5 | "description": "Project that tests the ability to npm install jupyter-js-widgets within an npm project.", 6 | "license": "BSD-3-Clause", 7 | "author": "IPython", 8 | "main": "index.js", 9 | "scripts": { 10 | "build": "webpack", 11 | "clean": "rimraf built", 12 | "test": "npm run test:firefox && npm run test:chrome", 13 | "test:chrome": "npm run test:default", 14 | "test:default": "karma start karma.config.js --log-level debug", 15 | "test:firefox": "npm run test:default -- --browsers Firefox", 16 | "test:firefox:headless": "npm run test:default -- --browsers=FirefoxHeadless" 17 | }, 18 | "dependencies": { 19 | "@jupyter-widgets/base": "^6.0.11", 20 | "@jupyter-widgets/base-manager": "^1.0.12", 21 | "@jupyter-widgets/controls": "^5.0.12" 22 | }, 23 | "devDependencies": { 24 | "chai": "^4.0.0", 25 | "css-loader": "^6.5.1", 26 | "karma": "^6.3.3", 27 | "karma-chai": "^0.1.0", 28 | "karma-chrome-launcher": "^3.1.0", 29 | "karma-firefox-launcher": "^2.1.1", 30 | "karma-mocha": "^2.0.1", 31 | "karma-mocha-reporter": "^2.2.5", 32 | "mocha": "^9.0.0", 33 | "style-loader": "^3.3.1", 34 | "webpack": "^5.65.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We appreciate contributions from the community. 4 | 5 | Click here to see the full [Guidelines](docs/source/contributing.md): 6 | 7 | - issues are managed by the `@meeseeksdev` bot 8 | - When opening an issue, make sure that it hasn't been solved 9 | - Search on Google or Github. 10 | - Include your system information 11 | 12 | ``` 13 | python -c "import IPython; print(IPython.sys_info())" 14 | ``` 15 | 16 | - **All work is submitted through pull requests (PRs)** 17 | - PRs are submitted as soon as there is code to be discussed 18 | 19 | --- 20 | 21 | # Check these resources: 22 | 23 | Now that we went through the basics, Here are more detailed documentation on areas of contribution: 24 | 25 | ## Installing 26 | 27 | [Developer install information](docs/source/dev_install.md) for installation steps. 28 | 29 | ## Releasing 30 | 31 | [Release procedures](docs/source/dev_release.md) 32 | 33 | ## Testing 34 | 35 | [Testing Contributions](docs/source/dev_testing.md) 36 | 37 | ## Documenting 38 | 39 | [Documentation Contributions](docs/source/dev_docs.md) 40 | 41 | --- 42 | 43 | # Good First Issues 44 | 45 | This is a link for issues that don't require deep knowledge of the project: 46 | 47 | Click here: [Good First Issues](https://github.com/jupyter-widgets/ipywidgets/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) 48 | -------------------------------------------------------------------------------- /examples/web3/src/manager.ts: -------------------------------------------------------------------------------- 1 | import * as base from '@jupyter-widgets/base'; 2 | import { Kernel } from '@jupyterlab/services'; 3 | 4 | import { HTMLManager } from '@jupyter-widgets/html-manager'; 5 | 6 | import './widgets.css'; 7 | 8 | export class WidgetManager extends HTMLManager { 9 | constructor(kernel: Kernel.IKernelConnection) { 10 | super(); 11 | this.kernel = kernel; 12 | 13 | kernel.registerCommTarget(this.comm_target_name, async (comm, msg) => { 14 | const oldComm = new base.shims.services.Comm(comm); 15 | await this.handle_comm_open(oldComm, msg); 16 | }); 17 | } 18 | 19 | /** 20 | * Create a comm. 21 | */ 22 | async _create_comm( 23 | target_name: string, 24 | model_id: string, 25 | data?: any, 26 | metadata?: any 27 | ): Promise { 28 | const comm = this.kernel.createComm(target_name, model_id); 29 | if (data || metadata) { 30 | comm.open(data, metadata); 31 | } 32 | return Promise.resolve(new base.shims.services.Comm(comm)); 33 | } 34 | 35 | /** 36 | * Get the currently-registered comms. 37 | */ 38 | _get_comm_info(): Promise { 39 | return this.kernel 40 | .requestCommInfo({ target_name: this.comm_target_name }) 41 | .then((reply) => (reply.content as any).comms); 42 | } 43 | 44 | kernel: Kernel.IKernelConnection; 45 | } 46 | -------------------------------------------------------------------------------- /python/widgetsnbextension/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = widgetsnbextension 3 | version = attr: widgetsnbextension._version.__version__ 4 | author = Jupyter Development Team 5 | author_email = jupyter@googlegroups.com 6 | url = http://jupyter.org 7 | description = Jupyter interactive widgets for Jupyter Notebook 8 | long_description = file: README.md 9 | long_description_content_type = text/markdown 10 | license_files = LICENSE 11 | license = BSD 3-Clause License 12 | platforms = Linux, Mac OS X, Windows 13 | keywords = Interactive, Interpreter, Shell, Web, notebook, widgets, Jupyter 14 | classifiers = 15 | Intended Audience :: Developers 16 | Intended Audience :: System Administrators 17 | Intended Audience :: Science/Research 18 | License :: OSI Approved :: BSD License 19 | Programming Language :: Python 20 | Programming Language :: Python :: 3 21 | Programming Language :: Python :: 3.9 22 | Programming Language :: Python :: 3.10 23 | Programming Language :: Python :: 3.11 24 | Programming Language :: Python :: 3.12 25 | Programming Language :: Python :: 3.13 26 | Programming Language :: Python :: 3 :: Only 27 | Framework :: Jupyter 28 | 29 | [options] 30 | python_requires = >=3.7 31 | zip_safe=False 32 | include_package_data = True 33 | packages = find: 34 | 35 | [options.package_data] 36 | widgetsnbextension = 37 | widgetsnbextension/static/extension.js 38 | -------------------------------------------------------------------------------- /packages/base/src/registry.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { Token } from '@lumino/coreutils'; 5 | 6 | import { WidgetModel, WidgetView } from './widget'; 7 | 8 | /** 9 | * A runtime interface token for a widget registry. 10 | */ 11 | export const IJupyterWidgetRegistry = new Token( 12 | 'jupyter.extensions.jupyterWidgetRegistry' 13 | ); 14 | 15 | /** 16 | * A registry of Jupyter Widgets. 17 | * 18 | * This is used by widget managers that support an external registry. 19 | */ 20 | export interface IJupyterWidgetRegistry { 21 | /** 22 | * Register a widget module. 23 | */ 24 | registerWidget(data: IWidgetRegistryData): void; 25 | } 26 | 27 | export type ExportMap = { 28 | [key: string]: typeof WidgetModel | typeof WidgetView; 29 | }; 30 | 31 | export type ExportData = 32 | | ExportMap 33 | | Promise 34 | | (() => ExportMap) 35 | | (() => Promise); 36 | 37 | export interface IWidgetRegistryData { 38 | /** 39 | * The widget module name. 40 | */ 41 | name: string; 42 | 43 | /** 44 | * The widget module version. 45 | */ 46 | version: string; 47 | 48 | /** 49 | * A map of object names to widget classes provided by the module, or a 50 | * promise to such a map, or a function returning the same. 51 | */ 52 | exports: ExportData; 53 | } 54 | -------------------------------------------------------------------------------- /examples/web4/README.md: -------------------------------------------------------------------------------- 1 | # Using the HTML widget manager 2 | 3 | ## Description 4 | 5 | This is an example project showing how to embed widgets in an HTML document. 6 | 7 | We use the local `index.built.js` that we build to make sure this example 8 | reflects the current state of the source repository. To use the latest release 9 | of the HTML widget manager in your own project, copy the `index.html` file and 10 | replace 11 | 12 | `` 13 | 14 | with 15 | 16 | `` 17 | 18 | If you need a specific version of the HTML widget manager, you can include a 19 | semver range. For example: 20 | 21 | `` 22 | 23 | The widget data in this example was generated from the following code: 24 | 25 | ```python 26 | from ipywidgets import VBox, jsdlink, IntSlider, Button 27 | 28 | s1, s2 = IntSlider(max=200, value=100), IntSlider(value=40) 29 | b = Button(icon='legal') 30 | jsdlink((s1, 'value'), (s2, 'max')) 31 | VBox([s1, s2, b]) 32 | ``` 33 | 34 | ## Try it 35 | 36 | 1. Start with a repository checkout, and run `yarn install` in the root directory. 37 | 2. Run `yarn build:examples` in the root directory. 38 | 3. Open the `index.html` file in this directory. 39 | -------------------------------------------------------------------------------- /docs/source/examples/images/align-self.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | flex-end 12 | flex-start 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /python/widgetsnbextension/src/save_state.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | 'use strict'; 5 | 6 | var save_state = function () { 7 | return new Promise(function (resolve, reject) { 8 | requirejs(['base/js/namespace'], function (Jupyter) { 9 | var wm = Jupyter.WidgetManager._managers[0]; 10 | if (!wm) { 11 | reject('No widget manager'); 12 | } 13 | return wm 14 | .get_state({ 15 | drop_defaults: true, 16 | }) 17 | .then(function (state) { 18 | var data = 19 | 'text/json;charset=utf-8,' + 20 | encodeURIComponent(JSON.stringify(state, null, ' ')); 21 | var a = document.createElement('a'); 22 | a.download = 'widget_state.json'; 23 | a.href = 'data:' + data; 24 | a.click(); 25 | resolve(); 26 | }); 27 | }); 28 | }); 29 | }; 30 | 31 | var action = { 32 | help: 'Download the widget state as a JSON file', 33 | icon: 'fa-sliders', 34 | help_index: 'zz', 35 | handler: save_state, 36 | }; 37 | 38 | var action_name = 'save-widget-state'; 39 | var prefix = 'widgets'; 40 | requirejs(['base/js/namespace'], function (Jupyter) { 41 | Jupyter.notebook.keyboard_manager.actions.register( 42 | action, 43 | action_name, 44 | prefix 45 | ); 46 | }); 47 | 48 | module.exports = { action: action }; 49 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'eslint:recommended', 4 | 'plugin:@typescript-eslint/eslint-recommended', 5 | 'plugin:@typescript-eslint/recommended', 6 | 'plugin:prettier/recommended', 7 | ], 8 | parser: '@typescript-eslint/parser', 9 | parserOptions: { 10 | project: './tsconfig.json', 11 | sourceType: 'module', 12 | tsconfigRootDir: __dirname, 13 | }, 14 | plugins: ['@typescript-eslint'], 15 | rules: { 16 | '@typescript-eslint/naming-convention': [ 17 | 'error', 18 | { 19 | selector: 'interface', 20 | format: ['PascalCase'], 21 | custom: { 22 | regex: '^I[A-Z]', 23 | match: true, 24 | }, 25 | }, 26 | ], 27 | '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], 28 | '@typescript-eslint/no-explicit-any': 'off', 29 | '@typescript-eslint/no-namespace': 'off', 30 | '@typescript-eslint/no-use-before-define': 'off', 31 | '@typescript-eslint/no-var-requires': 'off', 32 | '@typescript-eslint/no-non-null-assertion': 'off', 33 | '@typescript-eslint/ban-types': 'off', 34 | '@typescript-eslint/camelcase': 'off', 35 | '@typescript-eslint/quotes': [ 36 | 'error', 37 | 'single', 38 | { avoidEscape: true, allowTemplateLiterals: false }, 39 | ], 40 | curly: ['error', 'all'], 41 | eqeqeq: 'error', 42 | 'prefer-arrow-callback': 'error', 43 | }, 44 | }; 45 | -------------------------------------------------------------------------------- /packages/controls/css/nouislider.less: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | The nouislider.css file is autogenerated from nouislider.less, which imports and wraps the nouislider/src/nouislider.less styles. 4 | 5 | MIT License 6 | 7 | Copyright (c) 2019 Léon Gersen 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | /* The .widget-slider class is deprecated */ 17 | .widget-slider, .jupyter-widget-slider { 18 | @import "nouislider/src/nouislider.less"; 19 | @import (less) "./nouislider-custom.css"; 20 | }; 21 | -------------------------------------------------------------------------------- /docs/source/_templates/demo.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | 4 | Try Jupyter Widgets 5 |

6 | 7 |
8 | 18 | 27 | 34 | 35 | Try Now 36 | 37 |
38 | 39 | 40 | 45 |
46 | -------------------------------------------------------------------------------- /ui-tests/tests/widgets.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { test } from '@jupyterlab/galata'; 5 | 6 | import { expect } from '@playwright/test'; 7 | 8 | import * as path from 'path'; 9 | 10 | test.describe('Widget Visual Regression', () => { 11 | test.beforeEach(async ({ page, tmpPath }) => { 12 | await page.contents.uploadDirectory( 13 | path.resolve(__dirname, './notebooks'), 14 | tmpPath 15 | ); 16 | await page.filebrowser.openDirectory(tmpPath); 17 | }); 18 | 19 | test('Run notebook widgets.ipynb and capture cell outputs', async ({ 20 | page, 21 | tmpPath, 22 | }) => { 23 | const notebook = 'widgets.ipynb'; 24 | await page.notebook.openByPath(`${tmpPath}/${notebook}`); 25 | await page.notebook.activate(notebook); 26 | 27 | const captures = new Array(); 28 | const cellCount = await page.notebook.getCellCount(); 29 | 30 | await page.notebook.runCellByCell({ 31 | onAfterCellRun: async (cellIndex: number) => { 32 | const cell = await page.notebook.getCellOutput(cellIndex); 33 | if (cell) { 34 | captures.push(await cell.screenshot()); 35 | } 36 | }, 37 | }); 38 | 39 | await page.notebook.save(); 40 | 41 | for (let i = 0; i < cellCount; i++) { 42 | const image = `widgets-cell-${i}.png`; 43 | expect.soft(captures[i]).toMatchSnapshot(image); 44 | } 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /python/widgetsnbextension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jupyter-widgets/notebook-manager", 3 | "version": "8.0.15", 4 | "private": true, 5 | "description": "Jupyter Widgets nbextension", 6 | "homepage": "https://github.com/jupyter-widgets/ipywidgets#readme", 7 | "bugs": { 8 | "url": "https://github.com/jupyter-widgets/ipywidgets/issues" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/jupyter-widgets/ipywidgets.git" 13 | }, 14 | "license": "BSD-3-Clause", 15 | "author": "Jupyter Project", 16 | "main": "src/extension.js", 17 | "scripts": { 18 | "build": "npm run build:nbextension", 19 | "build:nbextension": "webpack", 20 | "clean": "rimraf widgetsnbextension/static", 21 | "prepublish": "npm run clean && npm run build", 22 | "watch": "npm run build --watch" 23 | }, 24 | "dependencies": { 25 | "@jupyter-widgets/base": "^6.0.11", 26 | "@jupyter-widgets/base-manager": "^1.0.12", 27 | "@jupyter-widgets/controls": "^5.0.12", 28 | "@jupyter-widgets/html-manager": "^1.0.14", 29 | "@jupyter-widgets/output": "^6.0.11", 30 | "@jupyterlab/services": "^6.0.0 || ^7.0.0", 31 | "@lumino/messaging": "^1 || ^2", 32 | "@lumino/widgets": "^1 || ^2", 33 | "backbone": "1.4.0" 34 | }, 35 | "devDependencies": { 36 | "css-loader": "^6.5.1", 37 | "requirejs": "^2.3.6", 38 | "rimraf": "^3.0.2", 39 | "style-loader": "^3.3.1", 40 | "webpack": "^5.65.0", 41 | "webpack-cli": "^4.7.2" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Project Jupyter Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /python/ipywidgets/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Project Jupyter Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /python/widgetsnbextension/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Project Jupyter Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /packages/html-manager/src/output_renderers.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { Widget } from '@lumino/widgets'; 5 | 6 | import { IRenderMime } from '@jupyterlab/rendermime-interfaces'; 7 | 8 | import { HTMLManager } from './htmlmanager'; 9 | 10 | export const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json'; 11 | 12 | // Renderer to allow the output widget to render sub-widgets 13 | export class WidgetRenderer extends Widget implements IRenderMime.IRenderer { 14 | constructor(options: IRenderMime.IRendererOptions, manager: HTMLManager) { 15 | super(); 16 | this.mimeType = options.mimeType; 17 | this._manager = manager; 18 | } 19 | 20 | async renderModel(model: IRenderMime.IMimeModel): Promise { 21 | const source: any = model.data[this.mimeType]; 22 | if (!this._manager.has_model(source.model_id)) { 23 | this.node.textContent = 'Error creating widget: could not find model'; 24 | this.addClass('jupyter-widgets'); 25 | return; 26 | } 27 | try { 28 | const wModel = await this._manager.get_model(source.model_id); 29 | const wView = await this._manager.create_view(wModel); 30 | Widget.attach(wView.luminoWidget || wView.pWidget, this.node); 31 | } catch (err) { 32 | console.log('Error displaying widget'); 33 | console.log(err); 34 | this.node.textContent = 'Error displaying widget'; 35 | this.addClass('jupyter-widgets'); 36 | } 37 | } 38 | 39 | /** 40 | * The mimetype being rendered. 41 | */ 42 | readonly mimeType: string; 43 | private _manager: HTMLManager; 44 | } 45 | -------------------------------------------------------------------------------- /docs/source/examples/images/flex-wrap.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/html-manager/test/webpack.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var postcss = require('postcss'); 3 | const webpack = require('webpack'); 4 | 5 | module.exports = { 6 | mode: 'development', 7 | entry: './test/build/index.js', 8 | output: { 9 | path: path.resolve(__dirname, 'build'), 10 | filename: 'bundle.js', 11 | }, 12 | bail: true, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | 'style-loader', 19 | 'css-loader', 20 | { 21 | loader: 'postcss-loader', 22 | options: { 23 | postcssOptions: { 24 | plugins: [ 25 | postcss.plugin('delete-tilde', function () { 26 | return function (css) { 27 | css.walkAtRules('import', function (rule) { 28 | rule.params = rule.params.replace('~', ''); 29 | }); 30 | }; 31 | }), 32 | postcss.plugin('prepend', function () { 33 | return function (css) { 34 | css.prepend( 35 | "@import '@jupyter-widgets/controls/css/labvariables.css';" 36 | ); 37 | }; 38 | }), 39 | require('postcss-import')(), 40 | require('postcss-cssnext')(), 41 | ], 42 | }, 43 | }, 44 | }, 45 | ], 46 | }, 47 | // required to load font-awesome 48 | { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' }, 49 | { test: /\.svg$/i, type: 'asset' }, 50 | ], 51 | }, 52 | }; 53 | -------------------------------------------------------------------------------- /packages/schema/v1/state.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "description": "Jupyter Interactive Widget State JSON schema.", 4 | "type": "object", 5 | "properties": { 6 | "version_major": { 7 | "description": "Format version (major)", 8 | "type": "number", 9 | "minimum": 1, 10 | "maximum": 1 11 | }, 12 | "version_minor": { 13 | "description": "Format version (minor)", 14 | "type": "number" 15 | }, 16 | "state": { 17 | "description": "Model State for All Widget Models", 18 | "type": "object", 19 | "additionalProperties": true, 20 | "additionalProperties": { 21 | "type": "object", 22 | "properties": { 23 | "model_name": { 24 | "description": "Name of the JavaScript class holding the model implementation", 25 | "type": "string" 26 | }, 27 | "model_module": { 28 | "description": "Name of the JavaScript module holding the model implementation", 29 | "type": "string" 30 | }, 31 | "model_module_version": { 32 | "description": "Semver range for the JavaScript module holding the model implementation", 33 | "type": "string" 34 | }, 35 | "state": { 36 | "description": "Serialized state of the model", 37 | "type": "object", 38 | "additional_properties": true 39 | } 40 | }, 41 | "required": ["model_name", "model_module", "state"], 42 | "additionalProperties": false 43 | } 44 | } 45 | }, 46 | "required": ["version_major", "version_minor", "state"], 47 | "additionalProperties": false 48 | } 49 | -------------------------------------------------------------------------------- /python/ipywidgets/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = ipywidgets 3 | version = attr: ipywidgets._version.__version__ 4 | author = Jupyter Development Team 5 | author_email = jupyter@googlegroups.com 6 | license_files = LICENSE 7 | description = Jupyter interactive widgets 8 | long_description = file: README.md 9 | long_description_content_type = text/markdown 10 | url = http://jupyter.org 11 | keywords = Interactive, Interpreter, Shell, Web, ipython, widgets, Jupyter 12 | platforms = Linux, Mac OS X, Windows 13 | license = BSD 3-Clause License 14 | classifiers = 15 | Intended Audience :: Developers 16 | Intended Audience :: System Administrators 17 | Intended Audience :: Science/Research 18 | License :: OSI Approved :: BSD License 19 | Programming Language :: Python 20 | Programming Language :: Python :: 3 21 | Programming Language :: Python :: 3.9 22 | Programming Language :: Python :: 3.10 23 | Programming Language :: Python :: 3.11 24 | Programming Language :: Python :: 3.12 25 | Programming Language :: Python :: 3.13 26 | Programming Language :: Python :: 3 :: Only 27 | Framework :: Jupyter 28 | 29 | [options] 30 | python_requires = >=3.7 31 | 32 | zip_safe = False 33 | # include_package_data = True 34 | packages = find: 35 | 36 | install_requires = 37 | comm>=0.1.3 38 | ipython>=6.1.0 39 | traitlets>=4.3.1 40 | widgetsnbextension~=4.0.14 41 | jupyterlab_widgets~=3.0.15 42 | 43 | [options.extras_require] 44 | test = 45 | jsonschema 46 | ipykernel 47 | pytest>=3.6.0 48 | pytest-cov 49 | pytz 50 | 51 | [options.package_data] 52 | ipywidgets = 53 | state.schema.json 54 | view.schema.json 55 | 56 | # Test data needs to be packaged until tests are moved out of module 57 | ipywidgets.widgets.tests = 58 | data/jupyter-logo-transparent.png 59 | -------------------------------------------------------------------------------- /docs/source/examples/images/flex-items.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | items 35 | 36 | -------------------------------------------------------------------------------- /packages/controls/src/widget_core.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | // widget_core implements some common patterns for the core widget collection 5 | // that are not to be used directly by third-party widget authors. 6 | 7 | import { DOMWidgetModel, WidgetModel } from '@jupyter-widgets/base'; 8 | 9 | import { DescriptionModel } from './widget_description'; 10 | 11 | import { JUPYTER_CONTROLS_VERSION } from './version'; 12 | 13 | export class CoreWidgetModel extends WidgetModel { 14 | defaults(): Backbone.ObjectHash { 15 | return { 16 | ...super.defaults(), 17 | _model_name: 'CoreWidgetModel', 18 | _view_module: '@jupyter-widgets/controls', 19 | _model_module: '@jupyter-widgets/controls', 20 | _view_module_version: JUPYTER_CONTROLS_VERSION, 21 | _model_module_version: JUPYTER_CONTROLS_VERSION, 22 | }; 23 | } 24 | } 25 | 26 | export class CoreDOMWidgetModel extends DOMWidgetModel { 27 | defaults(): Backbone.ObjectHash { 28 | return { 29 | ...super.defaults(), 30 | _model_name: 'CoreDOMWidgetModel', 31 | _view_module: '@jupyter-widgets/controls', 32 | _model_module: '@jupyter-widgets/controls', 33 | _view_module_version: JUPYTER_CONTROLS_VERSION, 34 | _model_module_version: JUPYTER_CONTROLS_VERSION, 35 | }; 36 | } 37 | } 38 | 39 | export class CoreDescriptionModel extends DescriptionModel { 40 | defaults(): Backbone.ObjectHash { 41 | return { 42 | ...super.defaults(), 43 | _model_name: 'CoreDescriptionModel', 44 | _view_module: '@jupyter-widgets/controls', 45 | _model_module: '@jupyter-widgets/controls', 46 | _view_module_version: JUPYTER_CONTROLS_VERSION, 47 | _model_module_version: JUPYTER_CONTROLS_VERSION, 48 | }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | from .widget import Widget, CallbackDispatcher, register, widget_serialization 5 | from .domwidget import DOMWidget 6 | from .valuewidget import ValueWidget 7 | 8 | from .trait_types import Color, Datetime, NumberFormat, TypedTuple 9 | 10 | from .widget_core import CoreWidget 11 | from .widget_bool import Checkbox, ToggleButton, Valid 12 | from .widget_button import Button, ButtonStyle 13 | from .widget_box import Box, HBox, VBox, GridBox 14 | from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider, FloatLogSlider 15 | from .widget_int import IntText, BoundedIntText, IntSlider, IntProgress, IntRangeSlider, Play, SliderStyle 16 | from .widget_color import ColorPicker 17 | from .widget_date import DatePicker 18 | from .widget_datetime import DatetimePicker, NaiveDatetimePicker 19 | from .widget_time import TimePicker 20 | from .widget_output import Output 21 | from .widget_selection import RadioButtons, ToggleButtons, ToggleButtonsStyle, Dropdown, Select, SelectionSlider, SelectMultiple, SelectionRangeSlider 22 | from .widget_selectioncontainer import Tab, Accordion, Stack 23 | from .widget_string import HTML, HTMLMath, Label, Text, Textarea, Password, Combobox 24 | from .widget_controller import Controller 25 | from .interaction import interact, interactive, fixed, interact_manual, interactive_output 26 | from .widget_link import jslink, jsdlink 27 | from .widget_layout import Layout 28 | from .widget_media import Image, Video, Audio 29 | from .widget_tagsinput import TagsInput, ColorsInput, FloatsInput, IntsInput 30 | from .widget_style import Style 31 | from .widget_templates import TwoByTwoLayout, AppLayout, GridspecLayout 32 | from .widget_upload import FileUpload 33 | -------------------------------------------------------------------------------- /docs/source/examples/images/flex-grow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 1 11 | 1 12 | 1 13 | 14 | 15 | 16 | 17 | 1 18 | 2 19 | 1 20 | 21 | -------------------------------------------------------------------------------- /dev-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # For a clean conda environment please read docs/source/dev_install.md 3 | 4 | set -x 5 | 6 | echo -n "Checking pip... " 7 | pip --version 8 | if [ $? -ne 0 ]; then 9 | echo "'pip --version' failed, therefore pip is not installed. In order to perform 10 | a developer install of ipywidgets you must have pip installed on 11 | your machine! See https://packaging.python.org/installing/ for installation instructions." 12 | exit 1 13 | fi 14 | 15 | echo -n "Checking JupyterLab (assuming JupyterLab >=4)... " 16 | jupyter lab --version 2>/dev/null 17 | if [ $? -ne 0 ]; then 18 | echo "no, skipping installation of widgets for jupyterlab" 19 | skip_jupyter_lab=yes 20 | fi 21 | 22 | 23 | # All following commands must run successfully 24 | set -e 25 | 26 | nbExtFlags="--sys-prefix $1" 27 | 28 | echo -n "Installing and building all yarn packages" 29 | jlpm 30 | jlpm build 31 | 32 | echo -n "widgetsnbextension" 33 | pip install -v -e ./python/widgetsnbextension 34 | if [[ "$OSTYPE" == "msys" ]]; then 35 | jupyter nbextension install --overwrite --py $nbExtFlags widgetsnbextension || true 36 | jupyter nbclassic-extension install --overwrite --py $nbExtFlags widgetsnbextension || true 37 | else 38 | jupyter nbextension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true 39 | jupyter nbclassic-extension install --overwrite --py --symlink $nbExtFlags widgetsnbextension || true 40 | fi 41 | jupyter nbextension enable --py $nbExtFlags widgetsnbextension || true 42 | jupyter nbclassic-extension enable --py $nbExtFlags widgetsnbextension || true 43 | 44 | echo -n "ipywidgets" 45 | pip install -v -e "./python/ipywidgets[test]" 46 | 47 | if test "$skip_jupyter_lab" != yes; then 48 | echo -n "jupyterlab_ipywidgets" 49 | pip install jupyter_packaging 50 | pip install -ve ./python/jupyterlab_widgets 51 | jupyter labextension develop ./python/jupyterlab_widgets --overwrite 52 | fi 53 | -------------------------------------------------------------------------------- /docs/source/examples/Controller.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Using Game Controllers in the Jupyter Notebook" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "The controller widget automatically detects connected gamepad and joysticks" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "# Imports for JupyterLite\n", 24 | "%pip install -q ipywidgets" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": { 31 | "tags": ["remove-cell"] 32 | }, 33 | "outputs": [], 34 | "source": [ 35 | "from ipywidgets import Controller" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "Controller()" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "In the case where multiple controllers are connected, you may address the controllers by index" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "Controller(index=1)" 61 | ] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3 (ipykernel)", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.10.5" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 2 85 | } 86 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Interactive widgets for the Jupyter notebook. 5 | 6 | Provide simple interactive controls in the notebook. 7 | Each Widget corresponds to an object in Python and Javascript, 8 | with controls on the page. 9 | 10 | To put a Widget on the page, you can display it with Jupyter's display machinery:: 11 | 12 | from ipywidgets import IntSlider 13 | slider = IntSlider(min=1, max=10) 14 | display(slider) 15 | 16 | Moving the slider will change the value. Most Widgets have a current value, 17 | accessible as a `value` attribute. 18 | """ 19 | 20 | # Must import __version__ first to avoid errors importing this file during the build process. See https://github.com/pypa/setuptools/issues/1724#issuecomment-627241822 21 | from ._version import __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__ 22 | 23 | import os 24 | import sys 25 | 26 | from traitlets import link, dlink 27 | from IPython import get_ipython 28 | 29 | from .widgets import * 30 | 31 | 32 | def load_ipython_extension(ip): 33 | """Set up Jupyter to work with widgets""" 34 | if not hasattr(ip, 'kernel'): 35 | return 36 | register_comm_target() 37 | 38 | def register_comm_target(kernel=None): 39 | """Register the jupyter.widget comm target""" 40 | from . import comm 41 | comm_manager = comm.get_comm_manager() 42 | if comm_manager is None: 43 | return 44 | comm_manager.register_target('jupyter.widget', Widget.handle_comm_opened) 45 | comm_manager.register_target('jupyter.widget.control', Widget.handle_control_comm_opened) 46 | 47 | def _handle_ipython(): 48 | """Register with the comm target at import if running in Jupyter""" 49 | ip = get_ipython() 50 | if ip is None: 51 | return 52 | register_comm_target() 53 | 54 | _handle_ipython() 55 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build jupyterlab_widgets 2 | 3 | on: 4 | push: 5 | branches: main 6 | pull_request: 7 | branches: '*' 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v4 15 | 16 | - name: Install Python 17 | uses: actions/setup-python@v4 18 | with: 19 | python-version: '3.13' 20 | architecture: 'x64' 21 | 22 | - name: Cache pip on Linux 23 | uses: actions/cache@v3 24 | if: startsWith(runner.os, 'Linux') 25 | with: 26 | path: ~/.cache/pip 27 | key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('**/requirements.txt') }} 28 | restore-keys: | 29 | ${{ runner.os }}-pip-${{ matrix.python }} 30 | 31 | - name: Install build dependencies 32 | run: | 33 | python -m pip install jupyterlab jupyter_packaging~=0.10 34 | 35 | - name: Install node dependencies 36 | run: | 37 | jlpm 38 | 39 | - name: Build node packages 40 | run: | 41 | jlpm build 42 | 43 | - name: Install jupyterlab_widgets 44 | run: | 45 | cd python/jupyterlab_widgets 46 | pip install -vv -e . --no-deps 47 | 48 | - name: Install widgetsnbextension 49 | run: | 50 | cd python/widgetsnbextension 51 | pip install -vv -e . --no-deps 52 | 53 | - name: Install ipywidgets 54 | run: | 55 | cd python/ipywidgets 56 | pip install -vv . --no-deps 57 | 58 | - name: Install development extension 59 | run: | 60 | cd python/jupyterlab_widgets 61 | jupyter labextension develop . --overwrite 62 | 63 | - name: List labextensions 64 | run: | 65 | jupyter labextension list 66 | 67 | - name: Run JupyterLab browser check 68 | run: | 69 | python -m jupyterlab.browser_check 70 | -------------------------------------------------------------------------------- /examples/web1/karma.config.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Mon Dec 07 2015 08:28:33 GMT-0800 (PST) 3 | 4 | module.exports = function (config) { 5 | var cfg = { 6 | // base path that will be used to resolve all patterns (eg. files, exclude) 7 | basePath: '', 8 | 9 | // frameworks to use 10 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 11 | frameworks: ['mocha', 'chai'], 12 | 13 | // list of files / patterns to load in the browser 14 | files: ['built/index.built.js', 'test/**/*.js'], 15 | 16 | // list of files to exclude 17 | exclude: [], 18 | 19 | // test results reporter to use 20 | // possible values: 'dots', 'progress' 21 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 22 | reporters: ['mocha'], 23 | 24 | // web server port 25 | port: 9876, 26 | 27 | // enable / disable colors in the output (reporters and logs) 28 | colors: true, 29 | 30 | // level of logging 31 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 32 | logLevel: config.LOG_INFO, 33 | browserNoActivityTimeout: 30000, 34 | 35 | // enable / disable watching file and executing tests whenever any file changes 36 | autoWatch: false, 37 | 38 | // start these browsers 39 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 40 | browsers: ['Chrome'], 41 | 42 | customLaunchers: { 43 | Chrome_travis_ci: { 44 | base: 'Chrome', 45 | flags: ['--no-sandbox'], 46 | }, 47 | }, 48 | 49 | // Continuous Integration mode 50 | // if true, Karma captures browsers, runs the tests and exits 51 | singleRun: true, 52 | 53 | // Concurrency level 54 | // how many browser should be started simultanous 55 | concurrency: Infinity, 56 | }; 57 | 58 | if (process.env.TRAVIS) { 59 | cfg.browsers = ['Chrome_travis_ci']; 60 | } 61 | 62 | config.set(cfg); 63 | }; 64 | -------------------------------------------------------------------------------- /examples/web1/manager.js: -------------------------------------------------------------------------------- 1 | var base = require('@jupyter-widgets/base'); 2 | var ManagerBase = require('@jupyter-widgets/base-manager').ManagerBase; 3 | var controls = require('@jupyter-widgets/controls'); 4 | var LuminoWidget = require('@lumino/widgets').Widget; 5 | 6 | class WidgetManager extends ManagerBase { 7 | constructor(el) { 8 | super(); 9 | this.el = el; 10 | } 11 | 12 | loadClass(className, moduleName, moduleVersion) { 13 | return new Promise(function (resolve, reject) { 14 | if (moduleName === '@jupyter-widgets/controls') { 15 | resolve(controls); 16 | } else if (moduleName === '@jupyter-widgets/base') { 17 | resolve(base); 18 | } else { 19 | var fallback = function (err) { 20 | let failedId = err.requireModules && err.requireModules[0]; 21 | if (failedId) { 22 | console.log( 23 | `Falling back to jsDelivr for ${moduleName}@${moduleVersion}` 24 | ); 25 | window.require( 26 | [ 27 | `https://cdn.jsdelivr.net/npm/${moduleName}@${moduleVersion}/dist/index.js`, 28 | ], 29 | resolve, 30 | reject 31 | ); 32 | } else { 33 | throw err; 34 | } 35 | }; 36 | window.require([`${moduleName}.js`], resolve, fallback); 37 | } 38 | }).then(function (module) { 39 | if (module[className]) { 40 | return module[className]; 41 | } else { 42 | return Promise.reject( 43 | `Class ${className} not found in module ${moduleName}@${moduleVersion}` 44 | ); 45 | } 46 | }); 47 | } 48 | 49 | display_view(view) { 50 | var that = this; 51 | return Promise.resolve(view).then((view) => { 52 | LuminoWidget.attach(view.luminoWidget, that.el); 53 | return view; 54 | }); 55 | } 56 | 57 | _get_comm_info() { 58 | return Promise.resolve({}); 59 | } 60 | 61 | _create_comm() { 62 | return Promise.reject('no comms available'); 63 | } 64 | } 65 | 66 | exports.WidgetManager = WidgetManager; 67 | -------------------------------------------------------------------------------- /examples/web2/manager.js: -------------------------------------------------------------------------------- 1 | var base = require('@jupyter-widgets/base'); 2 | var ManagerBase = require('@jupyter-widgets/base-manager').ManagerBase; 3 | var controls = require('@jupyter-widgets/controls'); 4 | var LuminoWidget = require('@lumino/widgets').Widget; 5 | 6 | class WidgetManager extends ManagerBase { 7 | constructor(el) { 8 | super(); 9 | this.el = el; 10 | } 11 | 12 | loadClass(className, moduleName, moduleVersion) { 13 | return new Promise(function (resolve, reject) { 14 | if (moduleName === '@jupyter-widgets/controls') { 15 | resolve(controls); 16 | } else if (moduleName === '@jupyter-widgets/base') { 17 | resolve(base); 18 | } else { 19 | var fallback = function (err) { 20 | let failedId = err.requireModules && err.requireModules[0]; 21 | if (failedId) { 22 | console.log( 23 | `Falling back to jsDelivr for ${moduleName}@${moduleVersion}` 24 | ); 25 | window.require( 26 | [ 27 | `https://cdn.jsdelivr.net/npm/${moduleName}@${moduleVersion}/dist/index.js`, 28 | ], 29 | resolve, 30 | reject 31 | ); 32 | } else { 33 | throw err; 34 | } 35 | }; 36 | window.require([`${moduleName}.js`], resolve, fallback); 37 | } 38 | }).then(function (module) { 39 | if (module[className]) { 40 | return module[className]; 41 | } else { 42 | return Promise.reject( 43 | `Class ${className} not found in module ${moduleName}@${moduleVersion}` 44 | ); 45 | } 46 | }); 47 | } 48 | 49 | display_view(view) { 50 | var that = this; 51 | return Promise.resolve(view).then(function (view) { 52 | LuminoWidget.attach(view.luminoWidget, that.el); 53 | return view; 54 | }); 55 | } 56 | 57 | _get_comm_info() { 58 | return Promise.resolve({}); 59 | } 60 | 61 | _create_comm() { 62 | return Promise.reject('no comms available'); 63 | } 64 | } 65 | 66 | exports.WidgetManager = WidgetManager; 67 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_widget_string.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | import inspect 5 | import pytest 6 | 7 | from ..widget_string import Combobox, Text 8 | 9 | def test_combobox_creation_blank(): 10 | w = Combobox() 11 | assert w.value == '' 12 | assert w.options == () 13 | assert w.ensure_option == False 14 | 15 | 16 | def test_combobox_creation_kwargs(): 17 | w = Combobox( 18 | value='Chocolate', 19 | options=[ 20 | "Chocolate", 21 | "Coconut", 22 | "Mint", 23 | "Strawberry", 24 | "Vanilla", 25 | ], 26 | ensure_option=True 27 | ) 28 | assert w.value == 'Chocolate' 29 | assert w.options == ( 30 | "Chocolate", 31 | "Coconut", 32 | "Mint", 33 | "Strawberry", 34 | "Vanilla", 35 | ) 36 | assert w.ensure_option == True 37 | 38 | def test_tooltip_deprecation(): 39 | caller_path = inspect.stack(context=0)[1].filename 40 | with pytest.deprecated_call() as record: 41 | w = Text(description_tooltip="testing") 42 | assert len(record) == 1 43 | assert record[0].filename == caller_path 44 | 45 | with pytest.deprecated_call() as record: 46 | w.description_tooltip 47 | assert len(record) == 1 48 | assert record[0].filename == caller_path 49 | 50 | with pytest.deprecated_call() as record: 51 | w.description_tooltip == "testing" 52 | assert len(record) == 1 53 | assert record[0].filename == caller_path 54 | 55 | with pytest.deprecated_call() as record: 56 | w.description_tooltip = "second value" 57 | assert len(record) == 1 58 | assert record[0].filename == caller_path 59 | assert w.tooltip == "second value" 60 | 61 | def test_on_submit_deprecation(): 62 | with pytest.deprecated_call() as record: 63 | Text().on_submit(lambda *args: ...) 64 | assert len(record) == 1 65 | assert record[0].filename == inspect.stack(context=0)[1].filename 66 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 13 | 14 | ## Description 15 | 16 | 17 | 18 | ## Reproduce 19 | 20 | 21 | 22 | 1. Go to '...' 23 | 2. Click on '...' 24 | 3. Scroll down to '...' 25 | 4. See error '...' 26 | 27 | 29 | 30 | ## Expected behavior 31 | 32 | 33 | 34 | ## Context 35 | 36 | 37 | 38 | - ipywidgets version 39 | - Operating System and version: 40 | - Browser and version: 41 | 42 |
Troubleshoot Output 43 |
44 | Paste the output from running `jupyter troubleshoot` from the command line here.
45 | You may want to sanitize the paths in the output.
46 | 
47 |
48 | 49 |
Command Line Output 50 |
51 | Paste the output from your command line running `jupyter lab` (or `jupyter notebook` if you use notebook) here, use `--debug` if possible.
52 | 
53 |
54 | 55 |
Browser Output 56 |
57 | Paste the output from your browser Javascript console here.
58 | 
59 |
60 | 61 | ### If using JupyterLab 62 | 63 | - JupyterLab version: 64 | 65 |
Installed Labextensions 66 |
67 | Paste the output from your command line running `jupyter labextension list`.
68 | 
69 |
70 | -------------------------------------------------------------------------------- /docs/source/examples/images/flex-direction1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/web1/index.js: -------------------------------------------------------------------------------- 1 | // Create a widget manager instance. 2 | var WidgetManager = require('./manager').WidgetManager; 3 | 4 | require('@jupyter-widgets/controls/css/widgets.css'); 5 | 6 | document.addEventListener('DOMContentLoaded', function (event) { 7 | var manager = new WidgetManager(document.body); 8 | 9 | /** 10 | * Helper function for creating and displaying widgets. 11 | * @return {Promise} 12 | */ 13 | function createWidget(widgetType, value, description) { 14 | // Create the widget model. 15 | return manager 16 | .new_model({ 17 | model_module: '@jupyter-widgets/controls', 18 | model_name: widgetType + 'Model', 19 | model_id: 'widget-1', 20 | // Create a view for the model. 21 | }) 22 | .then(function (model) { 23 | console.log(widgetType + ' model created'); 24 | 25 | model.set({ 26 | description: description || '', 27 | value: value, 28 | }); 29 | 30 | return manager.create_view(model); 31 | }, console.error.bind(console)) 32 | .then(function (view) { 33 | console.log(widgetType + ' view created'); 34 | manager.display_view(view); 35 | return view; 36 | }, console.error.bind(console)); 37 | } 38 | 39 | var defaultHTML = 'test text'; 40 | var textArea = createWidget('Textarea', defaultHTML, 'HTML:'); 41 | var html = createWidget('HTML', defaultHTML); 42 | 43 | // Create a link model. 44 | manager 45 | .new_model({ 46 | model_module: '@jupyter-widgets/controls', 47 | model_name: 'LinkModel', 48 | model_id: 'widget-2', 49 | state: { 50 | source: null, 51 | target: null, 52 | }, 53 | // Set the link model state. 54 | }) 55 | .then(function (link) { 56 | console.log('link created'); 57 | 58 | return Promise.all([textArea, html]).then(function (models) { 59 | console.log('setting link'); 60 | var textArea = models[0]; 61 | var html = models[1]; 62 | link.set({ 63 | source: [textArea.model, 'value'], 64 | target: [html.model, 'value'], 65 | }); 66 | link.save_changes(); 67 | console.log('link set'); 68 | }); 69 | }) 70 | .then(function () { 71 | var event = new Event('widgetsRendered'); 72 | document.dispatchEvent(event); 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /scripts/strip_examples.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """strip outputs from an IPython Notebook 4 | Opens a notebook, strips its output, and writes the outputless version to the original file. 5 | Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS. 6 | This does mostly the same thing as the `Clear All Output` command in the notebook UI. 7 | LICENSE: Public Domain 8 | From https://gist.github.com/minrk/6176788 9 | 10 | ls docs/source/examples/*.ipynb | xargs -I {} ./scripts/strip_examples.py "{}" 11 | 12 | After running this on the examples, re-run the outputs on: 13 | 14 | Using Interact.ipynb 15 | Output Widget.ipynb 16 | Image Browser.ipynb 17 | Widget Basics.ipynb 18 | Beat Frequencies.ipynb 19 | Lorenz Differential Equations.ipynb 20 | Widget Events.ipynb 21 | Export As (nbconvert).ipynb 22 | Exploring Graphs.ipynb 23 | Image Processing.ipynb 24 | Widget List.ipynb 25 | Widget Styling.ipynb 26 | Widget Low Level.ipynb 27 | Factoring.ipynb 28 | Widget Alignment.ipynb 29 | 30 | """ 31 | import io 32 | import sys 33 | 34 | try: 35 | # Jupyter >= 4 36 | from nbformat import read, write, NO_CONVERT 37 | except ImportError: 38 | # IPython 3 39 | try: 40 | from IPython.nbformat import read, write, NO_CONVERT 41 | except ImportError: 42 | # IPython < 3 43 | from IPython.nbformat import current 44 | 45 | def read(f, as_version): 46 | return current.read(f, 'json') 47 | 48 | def write(nb, f): 49 | return current.write(nb, f, 'json') 50 | 51 | 52 | def _cells(nb): 53 | """Yield all cells in an nbformat-insensitive manner""" 54 | if nb.nbformat < 4: 55 | for ws in nb.worksheets: 56 | yield from ws.cells 57 | else: 58 | yield from nb.cells 59 | 60 | 61 | def strip_output(nb): 62 | """strip the outputs from a notebook object""" 63 | nb.metadata.pop('signature', None) 64 | nb.metadata.pop('widgets', None) 65 | for cell in _cells(nb): 66 | if 'outputs' in cell: 67 | cell['outputs'] = [] 68 | if 'prompt_number' in cell: 69 | cell['prompt_number'] = None 70 | return nb 71 | 72 | 73 | if __name__ == '__main__': 74 | filename = sys.argv[1] 75 | with open(filename, 'r', encoding='utf8') as f: 76 | nb = read(f, as_version=NO_CONVERT) 77 | nb = strip_output(nb) 78 | with open(filename, 'w', encoding='utf8') as f: 79 | write(nb, f) 80 | -------------------------------------------------------------------------------- /examples/web3/src/index.ts: -------------------------------------------------------------------------------- 1 | import CodeMirror from 'codemirror'; 2 | import 'codemirror/lib/codemirror.css'; 3 | import 'codemirror/mode/python/python'; 4 | import 'font-awesome/css/font-awesome.css'; 5 | import { WidgetManager } from './manager'; 6 | 7 | import { 8 | KernelManager, 9 | ServerConnection, 10 | KernelMessage, 11 | } from '@jupyterlab/services'; 12 | 13 | const BASEURL = prompt('Notebook BASEURL', 'http://localhost:8888'); 14 | if (BASEURL === null) { 15 | alert('A base URL is needed to run the example!'); 16 | throw new Error('A base URL is needed to run the example!'); 17 | } 18 | const WSURL = 'ws:' + BASEURL.split(':').slice(1).join(':'); 19 | 20 | document.addEventListener('DOMContentLoaded', async function (event) { 21 | // Connect to the notebook webserver. 22 | const connectionInfo = ServerConnection.makeSettings({ 23 | baseUrl: BASEURL!, 24 | wsUrl: WSURL, 25 | }); 26 | const kernelManager = new KernelManager({ serverSettings: connectionInfo }); 27 | const kernel = await kernelManager.startNew(); 28 | 29 | // Create a codemirror instance 30 | const code = require('../widget_code.json').join('\n'); 31 | const inputarea = document.getElementsByClassName( 32 | 'inputarea' 33 | )[0] as HTMLElement; 34 | CodeMirror(inputarea, { 35 | value: code, 36 | mode: 'python', 37 | tabSize: 4, 38 | showCursorWhenSelecting: true, 39 | viewportMargin: Infinity, 40 | readOnly: true, 41 | }); 42 | 43 | // Create the widget area and widget manager 44 | const widgetarea = document.getElementsByClassName( 45 | 'widgetarea' 46 | )[0] as HTMLElement; 47 | const manager = new WidgetManager(kernel); 48 | 49 | // Run backend code to create the widgets. You could also create the 50 | // widgets in the frontend, like the other widget examples demonstrate. 51 | const execution = kernel.requestExecute({ code: code }); 52 | execution.onIOPub = async (msg): Promise => { 53 | // If we have a display message, display the widget. 54 | if (KernelMessage.isDisplayDataMsg(msg)) { 55 | const widgetData: any = 56 | msg.content.data['application/vnd.jupyter.widget-view+json']; 57 | if (widgetData !== undefined && widgetData.version_major === 2) { 58 | if (manager.has_model(widgetData.model_id)) { 59 | const model = await manager.get_model(widgetData.model_id)!; 60 | manager.display_view(manager.create_view(model), widgetarea); 61 | } 62 | } 63 | } 64 | }; 65 | }); 66 | -------------------------------------------------------------------------------- /python/jupyterlab_widgets/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "jupyterlab_widgets" 3 | description = "Jupyter interactive widgets for JupyterLab" 4 | readme = { file = "README.md", content-type = "text/markdown" } 5 | requires-python = ">=3.7" 6 | license = { file = "LICENSE" } 7 | authors = [ 8 | { name = "Jupyter Development Team", email = "jupyter@googlegroups.com" } 9 | ] 10 | keywords = [ 11 | "Interactive", "Interpreter", "Shell", "Web", "notebook", 12 | "widgets", "Jupyter", "JupyterLab", "JupyterLab3" 13 | ] 14 | classifiers = [ 15 | "Intended Audience :: Developers", 16 | "Intended Audience :: System Administrators", 17 | "Intended Audience :: Science/Research", 18 | "License :: OSI Approved :: BSD License", 19 | "Programming Language :: Python", 20 | "Programming Language :: Python :: 3", 21 | "Programming Language :: Python :: 3.9", 22 | "Programming Language :: Python :: 3.10", 23 | "Programming Language :: Python :: 3.11", 24 | "Programming Language :: Python :: 3.12", 25 | "Programming Language :: Python :: 3.13", 26 | "Programming Language :: Python :: 3 :: Only", 27 | "Framework :: Jupyter", 28 | "Framework :: Jupyter :: JupyterLab", 29 | "Framework :: Jupyter :: JupyterLab :: 3", 30 | "Framework :: Jupyter :: JupyterLab :: 4", 31 | "Framework :: Jupyter :: JupyterLab :: Extensions", 32 | "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt" 33 | ] 34 | urls = { Homepage = "https://github.com/jupyter-widgets/ipywidgets" } 35 | dynamic = ["version"] 36 | 37 | [tool.hatch.version] 38 | path = "jupyterlab_widgets/_version.py" 39 | 40 | [build-system] 41 | requires = ["hatchling>=1.5.0", "jupyterlab~=4.0"] 42 | build-backend = "hatchling.build" 43 | 44 | [tool.check-manifest] 45 | ignore = ["labextension/**", "yarn.lock", ".*", "package-lock.json"] 46 | 47 | [tool.hatch.build.hooks.jupyter-builder] 48 | ensured-targets = [ 49 | "labextension/package.json", 50 | ] 51 | dependencies = [ 52 | "hatch-jupyter-builder>=0.8.1", 53 | ] 54 | build-function = "hatch_jupyter_builder.npm_builder" 55 | skip-if-exists = ["labextension/static/style.js"] 56 | 57 | [tool.hatch.build.targets.wheel.shared-data] 58 | "install.json" = "share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/install.json" 59 | "labextension" = "share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager" 60 | 61 | [tool.hatch.build.hooks.jupyter-builder.build-kwargs] 62 | path = "." 63 | build_cmd = "build:prod" 64 | npm = [ 65 | "jlpm", 66 | ] 67 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/widget_description.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Contains the DOMWidget class""" 5 | 6 | from traitlets import Bool, Unicode 7 | from .widget import Widget, widget_serialization, register 8 | from .trait_types import InstanceDict 9 | from .widget_style import Style 10 | from .widget_core import CoreWidget 11 | from .domwidget import DOMWidget 12 | from .utils import deprecation 13 | 14 | import warnings 15 | 16 | @register 17 | class DescriptionStyle(Style, CoreWidget, Widget): 18 | """Description style widget.""" 19 | _model_name = Unicode('DescriptionStyleModel').tag(sync=True) 20 | description_width = Unicode(help="Width of the description to the side of the control.").tag(sync=True) 21 | 22 | 23 | class DescriptionWidget(DOMWidget, CoreWidget): 24 | """Widget that has a description label to the side.""" 25 | _model_name = Unicode('DescriptionModel').tag(sync=True) 26 | description = Unicode('', help="Description of the control.").tag(sync=True) 27 | description_allow_html = Bool(False, help="Accept HTML in the description.").tag(sync=True) 28 | style = InstanceDict(DescriptionStyle, help="Styling customizations").tag(sync=True, **widget_serialization) 29 | 30 | def __init__(self, *args, **kwargs): 31 | if 'description_tooltip' in kwargs: 32 | deprecation("the description_tooltip argument is deprecated, use tooltip instead") 33 | kwargs.setdefault('tooltip', kwargs['description_tooltip']) 34 | del kwargs['description_tooltip'] 35 | super().__init__(*args, **kwargs) 36 | 37 | def _repr_keys(self): 38 | for key in super()._repr_keys(): 39 | # Exclude style if it had the default value 40 | if key == 'style': 41 | value = getattr(self, key) 42 | if repr(value) == '%s()' % value.__class__.__name__: 43 | continue 44 | yield key 45 | 46 | @property 47 | def description_tooltip(self): 48 | """The tooltip information. 49 | .. deprecated :: 8.0.0 50 | Use tooltip attribute instead. 51 | """ 52 | deprecation(".description_tooltip is deprecated, use .tooltip instead") 53 | return self.tooltip 54 | 55 | @description_tooltip.setter 56 | def description_tooltip(self, tooltip): 57 | deprecation(".description_tooltip is deprecated, use .tooltip instead") 58 | self.tooltip = tooltip 59 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/tests/test_datetime_serializers.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) Vidar Tonaas Fauske. 4 | # Distributed under the terms of the Modified BSD License. 5 | 6 | import pytest 7 | 8 | import datetime 9 | import pytz 10 | 11 | from traitlets import TraitError 12 | 13 | from ..trait_types import ( 14 | time_to_json, 15 | time_from_json, 16 | datetime_to_json, 17 | datetime_from_json, 18 | ) 19 | 20 | 21 | def test_time_serialize_none(): 22 | assert time_to_json(None, None) == None 23 | 24 | 25 | def test_time_serialize_value(): 26 | t = datetime.time(13, 37, 42, 7000) 27 | assert time_to_json(t, None) == dict( 28 | hours=13, minutes=37, seconds=42, milliseconds=7 29 | ) 30 | 31 | 32 | def test_time_deserialize_none(): 33 | assert time_from_json(None, None) == None 34 | 35 | 36 | def test_time_deserialize_value(): 37 | v = dict(hours=13, minutes=37, seconds=42, milliseconds=7) 38 | assert time_from_json(v, None) == datetime.time(13, 37, 42, 7000) 39 | 40 | 41 | def test_datetime_serialize_none(): 42 | assert datetime_to_json(None, None) == None 43 | 44 | 45 | def test_datetime_serialize_value(): 46 | t = datetime.datetime(2002, 2, 20, 13, 37, 42, 7000, pytz.utc) 47 | assert datetime_to_json(t, None) == dict( 48 | year=2002, 49 | month=1, # Months are 0-based indices in JS 50 | date=20, 51 | hours=13, 52 | minutes=37, 53 | seconds=42, 54 | milliseconds=7, 55 | ) 56 | 57 | 58 | def test_datetime_serialize_non_utz(): 59 | # Non-existent timezone, so it will never be the local one: 60 | tz = pytz.FixedOffset(42) 61 | t = datetime.datetime(2002, 2, 20, 13, 37, 42, 7000, tz) 62 | assert datetime_to_json(t, None) == dict( 63 | year=2002, 64 | month=1, # Months are 0-based indices in JS 65 | date=20, 66 | hours=12, 67 | minutes=55, 68 | seconds=42, 69 | milliseconds=7, 70 | ) 71 | 72 | 73 | def test_datetime_deserialize_none(): 74 | assert datetime_from_json(None, None) == None 75 | 76 | 77 | def test_datetime_deserialize_value(): 78 | tz = pytz.FixedOffset(42) 79 | v = dict( 80 | year=2002, 81 | month=1, # Months are 0-based indices in JS 82 | date=20, 83 | hours=13, 84 | minutes=37, 85 | seconds=42, 86 | milliseconds=7, 87 | ) 88 | assert datetime_from_json(v, None) == datetime.datetime( 89 | 2002, 2, 20, 14, 19, 42, 7000, tz 90 | ) 91 | -------------------------------------------------------------------------------- /python/ipywidgets/ipywidgets/widgets/widget_controller.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Jupyter Development Team. 2 | # Distributed under the terms of the Modified BSD License. 3 | 4 | """Controller class. 5 | 6 | Represents a Gamepad or Joystick controller. 7 | """ 8 | 9 | from .valuewidget import ValueWidget 10 | from .widget import register, widget_serialization 11 | from .domwidget import DOMWidget 12 | from .widget_core import CoreWidget 13 | from .trait_types import TypedTuple 14 | from traitlets import Bool, Int, Float, Unicode, Instance 15 | 16 | 17 | @register 18 | class Button(DOMWidget, ValueWidget, CoreWidget): 19 | """Represents a gamepad or joystick button.""" 20 | value = Float(min=0.0, max=1.0, read_only=True, help="The value of the button.").tag(sync=True) 21 | pressed = Bool(read_only=True, help="Whether the button is pressed.").tag(sync=True) 22 | 23 | _view_name = Unicode('ControllerButtonView').tag(sync=True) 24 | _model_name = Unicode('ControllerButtonModel').tag(sync=True) 25 | 26 | 27 | @register 28 | class Axis(DOMWidget, ValueWidget, CoreWidget): 29 | """Represents a gamepad or joystick axis.""" 30 | value = Float(min=-1.0, max=1.0, read_only=True, help="The value of the axis.").tag(sync=True) 31 | 32 | _view_name = Unicode('ControllerAxisView').tag(sync=True) 33 | _model_name = Unicode('ControllerAxisModel').tag(sync=True) 34 | 35 | 36 | @register 37 | class Controller(DOMWidget, CoreWidget): 38 | """Represents a game controller.""" 39 | index = Int(help="The id number of the controller.").tag(sync=True) 40 | 41 | # General information about the gamepad, button and axes mapping, name. 42 | # These values are all read-only and set by the JavaScript side. 43 | name = Unicode(read_only=True, help="The name of the controller.").tag(sync=True) 44 | mapping = Unicode(read_only=True, help="The name of the control mapping.").tag(sync=True) 45 | connected = Bool(read_only=True, help="Whether the gamepad is connected.").tag(sync=True) 46 | timestamp = Float(read_only=True, help="The last time the data from this gamepad was updated.").tag(sync=True) 47 | 48 | # Buttons and axes - read-only 49 | buttons = TypedTuple(trait=Instance(Button), read_only=True, help="The buttons on the gamepad.").tag(sync=True, **widget_serialization) 50 | axes = TypedTuple(trait=Instance(Axis), read_only=True, help="The axes on the gamepad.").tag(sync=True, **widget_serialization) 51 | 52 | _view_name = Unicode('ControllerView').tag(sync=True) 53 | _model_name = Unicode('ControllerModel').tag(sync=True) 54 | -------------------------------------------------------------------------------- /packages/controls/src/widget_audio.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { DOMWidgetView } from '@jupyter-widgets/base'; 5 | 6 | import { CoreDOMWidgetModel } from './widget_core'; 7 | 8 | export class AudioModel extends CoreDOMWidgetModel { 9 | defaults(): Backbone.ObjectHash { 10 | return { 11 | ...super.defaults(), 12 | _model_name: 'AudioModel', 13 | _view_name: 'AudioView', 14 | format: 'mp3', 15 | autoplay: true, 16 | loop: true, 17 | controls: true, 18 | value: new DataView(new ArrayBuffer(0)), 19 | }; 20 | } 21 | 22 | static serializers = { 23 | ...CoreDOMWidgetModel.serializers, 24 | value: { 25 | serialize: (value: any): DataView => { 26 | return new DataView(value.buffer.slice(0)); 27 | }, 28 | }, 29 | }; 30 | } 31 | 32 | export class AudioView extends DOMWidgetView { 33 | render(): void { 34 | /** 35 | * Called when view is rendered. 36 | */ 37 | super.render(); 38 | this.luminoWidget.addClass('jupyter-widgets'); 39 | this.update(); // Set defaults. 40 | } 41 | 42 | update(): void { 43 | /** 44 | * Update the contents of this view 45 | * 46 | * Called when the model is changed. The model may have been 47 | * changed by another view or by a state update from the back-end. 48 | */ 49 | 50 | let url; 51 | const format = this.model.get('format'); 52 | const value = this.model.get('value'); 53 | if (format !== 'url') { 54 | const blob = new Blob([value], { 55 | type: `audio/${this.model.get('format')}`, 56 | }); 57 | url = URL.createObjectURL(blob); 58 | } else { 59 | url = new TextDecoder('utf-8').decode(value.buffer); 60 | } 61 | 62 | // Clean up the old objectURL 63 | const oldurl = this.el.src; 64 | this.el.src = url; 65 | if (oldurl) { 66 | URL.revokeObjectURL(oldurl); 67 | } 68 | 69 | // Audio attributes 70 | this.el.loop = this.model.get('loop'); 71 | this.el.autoplay = this.model.get('autoplay'); 72 | this.el.controls = this.model.get('controls'); 73 | 74 | return super.update(); 75 | } 76 | 77 | remove(): void { 78 | if (this.el.src) { 79 | URL.revokeObjectURL(this.el.src); 80 | } 81 | super.remove(); 82 | } 83 | 84 | preinitialize() { 85 | // Must set this before the initialize method creates the element 86 | this.tagName = 'audio'; 87 | } 88 | 89 | el: HTMLAudioElement; 90 | } 91 | --------------------------------------------------------------------------------