我正试图禁止用户关闭GTK窗口。
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def on_destroy(evt):
print("Please don't close me") # <- works
return False # <- doesn't work, the window closes
# return True # <- same behaviour as False
win = Gtk.Window()
win.connect('destroy', on_destroy)
win.show_all()
Gtk.main()
该事件已触发,但我不知道如何中断它。 destroy
可能为时已晚,我需要类似before_destroy
的东西吗?
有什么主意吗?谢谢!