开发者

Changing the action that the X button makes in PyQT

开发者 https://www.devze.com 2023-02-21 20:29 出处:网络
In the script im doing, im using processes, so when I close the GUI using the x button, I have some zombies, I have a method to kill all when the close button is clicked so I need to开发者_StackOverfl

In the script im doing, im using processes, so when I close the GUI using the x button, I have some zombies, I have a method to kill all when the close button is clicked so I need to开发者_StackOverflow社区 make the event of the x button to call this method, how can I do it?

Thanks in advance


You should be able to subclass the closeEvent of your window, call your function and then accept the event.

def closeEvent(self, event):
    kill_zombies()
    event.accept()

It would be nice if you update the user that the cleanup process is ongoing if it'll take a few seconds. Some users react badly to a close button that doesn't close right away and will just kill your app before the zombies have been zapped.

0

精彩评论

暂无评论...
验证码 换一张
取 消