[racket] racket/gui : How to properly code a two window system ?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jan 17 09:03:14 EST 2015

Let's make some assumptions: 

;; list-item.rkt
(define li (class object% ...))

;; add-item.rkt 
(define au (class object% ...))

Assuming a third file, main.rkt, links up these two files, why don't you parameterize the list-item class over add-item: 

(define li 
 (class object% (init-field an-instance-of-add-item) 
   ...
;; And further down you add a method add: 
   (define/public (callback event . x)
     (send an-instance-of-add-item add-item ... stuff ...))
 ))

-- Matthias





On Jan 17, 2015, at 8:15 AM, mazert wrote:

> Hello,
> 
> I have two files :
> 	* List-item.rkt : Display through a list-box% some items
> 	* add item.rkt : Display a form to add an item
> 
> 
> add-item window has different text-field% and a button% (label "ok")
> that create a new item stored in a variable foo and (send add-item show #f)
> 
> In the main window (list-item), I have a button% (label "Add"), and in
> the (callback) i would like to say something like :
> 
> (send add-item show #t)
> ; while add-item frame show equal #t, pause.
> (send list-item add foo) ; just for example to simplify.
> 
> I dont think it's a good algo to perform that. My question is about :
> how to send data created by add-item.rkt to List-item.rkt in the
> callback from the "add" button.
> 
> Thanks in advance.
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.