Issues when attaching and detaching external app from QDockWidget

后端 未结 1 1723
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 11:59

Consider this little piece of code:

import subprocess
import win32gui
import win32con
import time
import sys
from PyQt5.Qt          


        
相关标签:
1条回答
  • 2021-02-01 12:27

    I found part of the issue wrt to closing. So when you are creating the self._window in the attach function and you close the MainWindow, that other window (thread) is sitting around still. So if you add a self._window = None in the __init__ function and add a __del__ function as below, that part is fixed. Still not sure about the lack of menu. I'd also recommend holding onto the subprocess handle with self.__p instead of just letting that go. Include that in the __del__ as well.

        def __del__(self):
            self.__p.terminate()
            if self._window:
                print('terminating window')
                self._window.close
    

    Probably better yet would be to include a closeEvent

        def closeEvent(self, event):
            print('Closing time')
            self.__p.terminate()
            if self._window is not None:
                print('terminating window')
                self._window.close
    
    0 讨论(0)
提交回复
热议问题