printing from custom loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by reading ipykernel/eventloops.py alongside the custom loop's cb() call and kernel.shell_stream.flush(limit=1) handling. Reproduce the %gui imgui flow in either the Jupyter web UI or IntelliJ IDEA, then verify that print('123') from imgui_app() appears before the app closes.
Written by the indexing model from the issue text.
Description
I made a custom event loop for Dear ImGui. Everything works fine, except i can not find a way to produce any output from within the loop where UI code runs. This is the loop:
from ipykernel.eventloops import register_integration
@register_integration('imgui')
def loop_imgui(kernel):
import imgui
app = None
try:
while not kernel.shell.exit_now:
if len(imgui._ipython_callbacks) > 0:
title, cb = imgui._ipython_callbacks[0]
if app is None:
app = imgui.DearImGuiApp(title)
do_continue = False
if app.begin_frame():
try:
do_continue = cb()
finally:
app.end_frame()
if not do_continue:
app.close()
app = None
del imgui._ipython_callbacks[0]
if kernel.shell_stream.flush(limit=1):
break
except Exception as e:
kernel.log.exception(e)
finally:
imgui._ipython_callbacks = []
if app is not None:
app.close()
app = None
@loop_imgui.exit
def loop_imgui_exit(kernel):
pass
def load_ipython_extension(ipython):
pass
def unload_ipython_extension(ipython):
pass
I use it as follows:
%load_ext imgui_loop
%gui imgui
import imgui
@imgui.ipython_window('Charts')
def imgui_app():
print('123')
return False
Im sorry about this code not being testable as i do not have all parts available on github.. But basically imgui_app() gets called on the line do_continue = cb() in the loop code. It should print '123' and then imgui app gets closed. I do not see any text printed though, documentation mentions nothing about it either and ipykernel/eventloops.py does imply printing should just work..? But somehow it does not. I tested it from IntelliJ IDEA as well as from Jupyter web UI - result is same. Other than this, imgui UI works just fine. Any ideas what i could be missing?
Thanks 🙏
- Dominant language
- Python
- Stars
- 734
- Forks
- 411
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ipython/ipykernel
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
ipython/ipykernel#1550 · 1 comment · 1 reaction · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
All issues in ipython/ipykernel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·