首页 文章

如何在Racket中处理GUI退出?

提问于
浏览
7

我的Racket GUI应用程序在退出时需要做很多清理工作,即当用户按下X按钮时 . 这些包括杀死子进程(在Windows上不是自动进程)等 .

将.rkt包装在shell脚本中等待然后进行清理对我来说有点过于讨厌 . Racket文档中有许多退出处理程序(退出处理程序等),但它们似乎都不起作用!

1 回答

  • 9

    你可能想在 frame% 中增加 on-close ,例如:

    #lang racket/gui
    
    (send
     (new (class frame% (super-new)
            (define/augment (on-close)
              (displayln "Exiting...")))
          [label "Frame"]
          [width 400] [height 200])
     show #t)
    

    当我点击结束十字架时,在我的机器上打印出“退出...” .

相关问题