After running an open3d window and closing it, tkinter messagebox crashes and gives X Error of failed request: BadWindow (invalid Window Parameter)

huangapple go评论59阅读模式
英文:

After running an open3d window and closing it, tkinter messagebox crashes and gives X Error of failed request: BadWindow (invalid Window Parameter)

问题

我正在尝试在关闭open3d窗口后添加一个消息框的是/否问题

重现错误的代码
```python
open3d.visualization.draw_geometries([])
#创建是/否对话框
dialog_result = messagebox.askquestion("Remove Object", "Remove Object?", icon='warning')

我在网上找不到答案,而且ChatGPT给我提供了一个我不理解的通用答案。如果有人遇到类似的问题,我将不胜感激地知道你是如何处理这个错误的。

提前致谢。

点击“是”后产生的错误:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  15 (X_QueryTree)
  Resource id in failed request:  0x6a04d88
  Serial number of failed request:  58195
  Current serial number in output stream:  58195
英文:

I am trying to add a messagebox yes no question after closing a open3d window.

code to reproduce the error:

open3d.visualization.draw_geometries([])
#create yes no
dialougdialog = messagebox.askquestion("Remove Object", "Remove Object?", icon='warning')

i cant find an answer online and chatgpt gives me a generic answer that I don't understand.
if someone had this issue or similar i would be grateful to know how you handled this error.

Thank you in advance.

the error produce after clicking on "yes":

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  15 (X_QueryTree)
  Resource id in failed request:  0x6a04d88
  Serial number of failed request:  58195
  Current serial number in output stream:  58195

答案1

得分: 1

我猜你正在经历与以下已关闭的Open3D问题相同的问题,该问题使用旧的可视化GUI组件。

https://github.com/isl-org/Open3D/issues/1715

正如在那里所述,迄今为止找到的最佳解决方案是切换到基于新Filament的GUI,因为该GUI能够识别Open3D可视化GL代码未控制的其他窗口。

简而言之,可视化方法将GL窗口的焦点切换到前台,然后假设在同一程序中没有其他窗口窃取焦点。因此,当切换到Tkinter GUI时,Open3D可视化代码将不会注意到它没有访问权限的Tkinter窗口而不是GL窗口。 - 任何其他程序在进入GL绘图代码时都会确保它正在绘制到正确的窗口并且抓取焦点。

编辑:
上面对你在帖子中写的内容是正确的。但是当你指的是你在标题中写的内容:“在运行Open3D窗口并关闭它后,Tkinter消息框崩溃并显示X错误:请求失败:BadWindow(无效的窗口参数)”。

你的帖子让我以为可视化窗口仍然打开。那么你是关闭可视化窗口然后打开Tkinter窗口,还是在Open3D可视化窗口打开的同时打开Tkinter窗口?

编辑
在我的项目中进行了一些研究。Tkinter是一个可恶的无视野兽。最终,我不得不使用subprocess模块来隔离filedialog.askdirectorymessagebox.askyesnocancel。你可以在https://github.com/isl-org/Open3D/issues/6125找到我的解决方案。

很抱歉,我没有比说Tkinter是坏和邪恶更好的消息。

英文:

I guess you are experiencing the same as described in the following already closed open3d issue using the old visualization gui stuff.

https://github.com/isl-org/Open3D/issues/1715

As stated there the best solution found so far is to switch to the new filament based gui as that is aware of other windows not controlled by open3d visualization gl code.

The sort answer is that visualization methods switch focus of gl window to front and than assume that no other window in the same program steals them the focus. Consequently when switching to tkinter gui open3d visualization code will not notice that it is not drawing to gl window but to the tkinter which it has no access to. - Any other program would whenever entering gl drawing code simply ensure that it is drawing to the right window and grab focus.

EDIT:
The above is true for what you have written in your post. But it is not true when you meant what you have put in headline "After running an open3d window and closing it, tkinter messagebox crashes and gives X Error of failed request: BadWindow (invalid Window Parameter)".

Your post made me assume the visualization window is still open. So do you close the visualization window and then open the tkinter window or open the tkinter window while the open3d visualization is open?

EDIT
Did some research in my own project. Tkinter is the nasty ignoring beast. I finally resorted to use subprocess module to sandbox the filedialog.askdirectory and messagebox.askyesnocanel. My solution you can find on https://github.com/isl-org/Open3D/issues/6125 .

Sorry not having better news than saying Tkinter is the bad and evil.

huangapple
  • 本文由 发表于 2023年4月4日 16:46:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927299.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定