printing from custom loop
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 38/100
调研方向
首先阅读 ipykernel/eventloops.py,同时查看自定义循环的 cb() 调用以及 kernel.shell_stream.flush(limit=1) 的处理。然后在 Jupyter web UI 或 IntelliJ IDEA 中复现 %gui imgui 流程,并确认 imgui_app() 中的 print('123') 会在应用关闭前出现。
由索引模型根据 Issue 内容生成。
描述
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 🙏
- 主要语言
- Python
- 星标
- 734
- 派生
- 411
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 9
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ipython/ipykernel 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 72/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 4/5 3-5 天 新手友好度 68/100
查看 ipython/ipykernel 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
canonical/paas-charm#368 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
tech debt
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
qualcomm/qai-appbuilder#275 ·