|
33 | 33 | "metadata": {}, |
34 | 34 | "outputs": [], |
35 | 35 | "source": [ |
36 | | - "import asyncio\n", |
| 36 | + "import anyio\n", |
37 | 37 | "\n", |
38 | 38 | "import ipylab\n", |
39 | 39 | "from ipylab.code_editor import CodeEditorOptions" |
|
51 | 51 | " mime_type=\"text/x-python\",\n", |
52 | 52 | " description=\"<b>Code editor</b>\",\n", |
53 | 53 | " tooltip=\"This is a code editor. Code completion is provided for Python\",\n", |
54 | | - " value=\"def test():\\n ipylab.app.notification.notify('CodeEditor evaluation')\\n\\n# Place the cursor in the CodeEditor and press `Shift Enter`\\ntest()\",\n", |
| 54 | + " value=\"def test():\\n app.notification.notify('CodeEditor evaluation')\\n\\n# Place the cursor in the CodeEditor and press `Shift Enter`\\ntest()\",\n", |
55 | 55 | " layout={\"height\": \"120px\", \"overflow\": \"hidden\"},\n", |
56 | 56 | " description_allow_html=True,\n", |
57 | 57 | ")\n", |
58 | | - "asyncio.get_event_loop().call_later(0.5, ce.focus)\n", |
59 | | - "ce" |
| 58 | + "display(ce)\n", |
| 59 | + "await ce.ready()\n", |
| 60 | + "ce.focus()" |
60 | 61 | ] |
61 | 62 | }, |
62 | 63 | { |
|
123 | 124 | "\n", |
124 | 125 | "\n", |
125 | 126 | "async def test():\n", |
126 | | - " import asyncio\n", |
127 | 127 | " import random\n", |
128 | 128 | "\n", |
129 | 129 | " for _ in range(20):\n", |
130 | 130 | " ce.value = random.choice(values) # noqa: S311\n", |
131 | | - " await asyncio.sleep(random.randint(10, 300) / 1e3) # noqa: S311" |
| 131 | + " await anyio.sleep(random.randint(10, 300) / 1e3) # noqa: S311" |
132 | 132 | ] |
133 | 133 | }, |
134 | 134 | { |
|
148 | 148 | "metadata": {}, |
149 | 149 | "outputs": [], |
150 | 150 | "source": [ |
151 | | - "t = ce.to_task(test())" |
| 151 | + "await test()" |
152 | 152 | ] |
153 | 153 | }, |
154 | 154 | { |
|
157 | 157 | "id": "11", |
158 | 158 | "metadata": {}, |
159 | 159 | "outputs": [], |
160 | | - "source": [ |
161 | | - "t.cancel()" |
162 | | - ] |
163 | | - }, |
164 | | - { |
165 | | - "cell_type": "code", |
166 | | - "execution_count": null, |
167 | | - "id": "12", |
168 | | - "metadata": {}, |
169 | | - "outputs": [], |
170 | 160 | "source": [ |
171 | 161 | "# Place the label above\n", |
172 | 162 | "ce.layout.flex_flow = \"column\"" |
|
175 | 165 | { |
176 | 166 | "cell_type": "code", |
177 | 167 | "execution_count": null, |
178 | | - "id": "13", |
| 168 | + "id": "12", |
179 | 169 | "metadata": {}, |
180 | 170 | "outputs": [], |
181 | 171 | "source": [ |
182 | 172 | "# Add the same editor to the shell.\n", |
183 | | - "ipylab.app.shell.add(ce)" |
| 173 | + "await ce.app.shell.add(ce)" |
184 | 174 | ] |
185 | 175 | }, |
186 | 176 | { |
187 | 177 | "cell_type": "markdown", |
188 | | - "id": "14", |
| 178 | + "id": "13", |
189 | 179 | "metadata": {}, |
190 | 180 | "source": [ |
191 | 181 | "### Other mime_types\n", |
|
196 | 186 | { |
197 | 187 | "cell_type": "code", |
198 | 188 | "execution_count": null, |
199 | | - "id": "15", |
| 189 | + "id": "14", |
200 | 190 | "metadata": {}, |
201 | 191 | "outputs": [], |
202 | 192 | "source": [ |
|
206 | 196 | { |
207 | 197 | "cell_type": "code", |
208 | 198 | "execution_count": null, |
209 | | - "id": "16", |
| 199 | + "id": "15", |
210 | 200 | "metadata": {}, |
211 | 201 | "outputs": [], |
212 | 202 | "source": [ |
|
230 | 220 | "name": "python", |
231 | 221 | "nbconvert_exporter": "python", |
232 | 222 | "pygments_lexer": "ipython3", |
233 | | - "version": "3.11.10" |
| 223 | + "version": "3.12.9" |
234 | 224 | } |
235 | 225 | }, |
236 | 226 | "nbformat": 4, |
|
0 commit comments