我有一个 Python 程序,它通过 COM 从另一个程序获取窗口句柄(将 Python 程序视为插件)我将此窗口设置为主要 Python 框架的父级,这样如果另一个程序最小化,python 框架也会. 问题是当我退出并尝试关闭或销毁主框架时,frame.close 永远不会完成它的执行(尽管它确实消失了)并且其他程序拒绝关闭,除非被 TaskManager 杀死。
以下是我们大致采取的步骤:
if we are started directly, launch other program
if not, we are called from the other program, do nothing
enter main function:
create new wx.App
set other program as frame parent:
Get handle via COM
create a parent using wx.Window_FromHWND
create new frame with handle as parent
show frame
enter main loop
App.onexit:
close frame
frame = None
handle as parent = None
handle = None
有人对此有任何想法或经验吗?
我很感激这方面的任何帮助!
[编辑]只有当我使用句柄作为父级时才会出现这种情况,如果我只是获取句柄并关闭python程序,其他程序关闭正常