Skip to content

[WIP] IPyWidgets Backend for TraitsUI #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
edd78d1
Initial commit of ipywidgets toolkit code.
corranwebster Jul 14, 2018
be0f877
WIP: First cut of bool and text editors.
prabhuramachandran Jul 15, 2018
1e12dcf
First working widgets.
corranwebster Jul 15, 2018
9017638
Test Jupyter notebook.
corranwebster Jul 15, 2018
a73b3f2
Get grid layouts working.
corranwebster Jul 15, 2018
60ca4a9
Add button_editor file
ku-ya Jul 15, 2018
2ffcfb4
More work on getting things up and running. Tabbed and VFold now work.
corranwebster Jul 15, 2018
1c4c74d
ENH: add html editor for ipywidgets
ku-ya Jul 15, 2018
23b8535
CLN: remove button editor from ipywidgets
ku-ya Jul 15, 2018
285e634
FLK: remove unused import
ku-ya Jul 15, 2018
8844c59
Merge pull request #470 from enthought/enh/ipywidgets-html-editor
corranwebster Jul 15, 2018
d5b6d62
Adding a range editor.
prabhuramachandran Jul 21, 2018
e622c7b
Adding a very simple button editor.
prabhuramachandran Jul 22, 2018
21e7529
Update notebook with more traits.
prabhuramachandran Jul 22, 2018
c9bc71c
Allow traits object to be immediately displayed.
prabhuramachandran Jul 22, 2018
9627db2
Mirror changes in #473.
prabhuramachandran Jul 25, 2018
a37da63
First cut at image support for IPyWidgets (untested).
corranwebster Jul 30, 2018
913c5c8
Get image editor working.
corranwebster Jul 13, 2019
b1c6069
First attempt at a date editor.
corranwebster Jul 13, 2019
8babcf8
Merge branch 'master' into feature/ipywidgets-backend
corranwebster Jul 13, 2019
8d212fc
Add stubbed-out pyface action API to avoid import errors.
corranwebster Jul 13, 2019
398f41b
Clean up HasTraits patching.
corranwebster Jul 13, 2019
1f90ac9
Better way of adding Jupyter HTML rendering of traits.
corranwebster Jul 13, 2019
02f3d97
Merge branch 'master' of github.com:enthought/traitsui into feature/i…
Apr 27, 2021
a166c26
FIX : Ignore flake8 errors in traitsui.ipywidgets for now
Apr 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow traits object to be immediately displayed.
This is convenient but the injected method definitely belongs elsewhere.
  • Loading branch information
prabhuramachandran committed Jul 22, 2018
commit c9bc71cb0b47fd89973140e1e3a544ce73df082c
143 changes: 23 additions & 120 deletions traitsui/ipywidgets/TestIPyWidgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -65,28 +65,17 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<__main__.TestObjInline at 0x10a1478e0>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"t1 = TestObjInline()\n",
"t1"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -116,93 +105,44 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tab(children=(GridBox(children=(Label(value='test'), Label(value=''), Label(value='Text:'), Text(value='')), layout=Layout(grid_template_columns='auto auto')), GridBox(children=(Label(value='Boolean:'), Checkbox(value=False), Label(value='Integer:'), Text(value='0')), layout=Layout(grid_template_columns='auto auto'))), _titles={'0': 'Tab 1', '1': 'Tab 2'})\n"
]
}
],
"outputs": [],
"source": [
"print(ui.control)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4503d7dc6a3a4d1fbc05b8cc727265f9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(GridBox(children=(Label(value='test'), Label(value=''), Label(value='Text:'), Text(value='')), l…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"t = ui.control\n",
"t"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d861bee9d0db4fff9da86ce049d860c2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(GridBox(children=(Label(value='test'), Label(value=''), Label(value='Text:'), Text(value='')), l…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"test_obj.configure_traits(view=test_view, kind='live')\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"''"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"test_obj.text"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -211,47 +151,25 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"test_obj.boolean"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"test_obj.integer"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -260,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -269,24 +187,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e8bf7960786f436890895053c2b427e4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"GridBox(children=(Button(layout=Layout(height='auto', width='auto'), style=ButtonStyle(button_color='darkseagr…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from ipywidgets import GridBox, Button, ButtonStyle, Layout\n",
"gb = GridBox(children=[Button(layout=Layout(width='auto', height='auto'),\n",
Expand Down
8 changes: 8 additions & 0 deletions traitsui/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import logging

from traits.trait_base import ETSConfig
from traits.has_traits import HasTraits
from pyface.base_toolkit import Toolkit, find_toolkit


Expand All @@ -35,6 +36,13 @@
_toolkit = None


# FIXME: this definitely belongs elsewhere.
# An injected method to render the object in a Jupyter notebook.
def _repr_html_(self):
self.configure_traits(kind='live')
HasTraits._repr_html_ = _repr_html_


def assert_toolkit_import(names):
""" Raise an error if a toolkit with the given name should not be allowed
to be imported.
Expand Down