Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle GUI exit in Racket?

Tags:

events

racket

My Racket GUI application needs to do a lot of cleanup work when exiting, i.e. when the user presses the X button. These include killing child processes (which isn't automatic on Windows) etc.

Wrapping the .rkt in a shell script which waits and then does the cleanup is a bit too hacky for me. There are many exit handlers in the Racket documentation (exit-handler etc) but none of them seem to work!

like image 897
ithisa Avatar asked Sep 08 '13 13:09

ithisa


1 Answers

You probably want to augment on-close in frame%, for example:

#lang racket/gui

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

which on my machine prints "Exiting..." when I click the closing cross.

like image 160
Metaxal Avatar answered Oct 21 '22 14:10

Metaxal