python-3.x - 关闭 Imgui 窗口:这看起来应该很容易。如何做到这一点?
问题描述
我已经开始使用该imgui
系统来可视化“任何东西”。我在我最初的几个小时里,并且遇到了似乎很常见的障碍。
然而,尽管我可以看到对 ImGui 的 C++ 版本的一些很好的支持(我将最终过渡到),但 python imgui 的内容大多是模糊的。
我正在寻找的是以下问题的解决方案:
while not glfw.window_should_close(window):
...
imgui.new_frame()
imgui.begin("foo-window", closable=True)
imgui.end()
一切正常。但是,窗口并没有关闭。我知道窗口不会关闭,因为它总是在每个循环中创建。
我正在寻找的是:
如何检测和识别特定窗口已关闭,并阻止它重新生成?
解决方案
我对 Python 的 imGui 一点也不熟悉,但如果它完全遵循与 imGui for c++ 类似的模式,那么您需要遵循以下模式:
static bool show_welcome_popup = true;
if(show_welcome_popup)
{
showWelcomePopup(&show_welcome_popup);
}
void showWelcomePopup(bool* p_open)
{
//The window gets created here. Passing the bool to ImGui::Begin causes the "x" button to show in the top right of the window. Pressing the "x" button toggles the bool passed to it as "true" or "false"
//If the window cannot get created, it will call ImGui::End
if(!ImGui::Begin("Welcome", p_open))
{
ImGui::End();
}
else
{
ImGui::Text("Welcome");
ImGui::End();
}
}
推荐阅读
- excel - 对象不支持此属性或方法:Workbooks.Worksheets.Range
- shopify - 根据产品中的复选框在shopify中添加自定义标签到订单
- python - 使用python中的递归将YAML分层数据导出到CSV文件
- asp.net - VB 代码中无法访问 WebForms ScriptManager 标记
- github - 需要从 github 下载所有具有大量历史记录的审计日志
- javascript - Kraken API 私有请求身份验证 {"error":["EAPI:Invalid key"]} - Google 脚本
- python - 仅打印一批信息的代码
- javascript - javascript中的window.location.href只是重新加载页面,而不是导航到另一个网站
- java - Flutter:无法解析配置“:path_provider:classpath”的所有工件
- angular - 直到刷新才会删除