[plt-scheme] middle ground between MrEd and gui/draw teachpacks?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Feb 9 13:42:39 EST 2005

At Wed, 9 Feb 2005 13:17:42 -0500, Prabhakar Ragde wrote:
> [*] Popping up a help window is something I still can't do easily
> except with message-box, even in full MrEd. I think I'm missing
> something.

I'll add something like this to the "mrlib" collection:

(module show-file (lib "plt-mred.ss" "lang")
  (require (lib "etc.ss"))
  (provide make-show-file)
  
  ;; make-show-file : path str [num num] -> (-> (void))
  ;;  Makes a procedure to open a window to show a file,
  ;;  or bring an existing window to the front
  (define make-show-file
    (opt-lambda (path title [w 640] [h 480])
      (let ([f #f])
        (lambda ()
          (unless f
            (let ([t (new text%)])
              (send t load-file path)
              (send t lock #t)
              (set! f (new frame% 
                           [label title]
                           [width w]
                           [height h]))
              (new editor-canvas% [parent f][editor t])))
          (send f show #t))))))


Example interaction:

 > (define show-file (make-show-file (find-system-path 'pref-file) "My Prefs"))
 > (show-file) ; shows the window
 > (show-file) ; brings it to the front


Matthew



Posted on the users mailing list.