Modules and class oddities (Was: [plt-scheme] Dialog% not accepting frame% subclasses as parent?)

From: Erich Rast (Erich.Rast at t-online.de)
Date: Thu Oct 17 13:10:47 EDT 2002

I've solved my problem. The bug was: My alert dialog initialization was 
inside a module while the parent dialog definition was outside of it. 
Therefore, the exported alert-macro complained that the parent dialog 
was not of class frame%.

Solution: I moved the parent dialog class definition in another module, 
and made the alert module require it.

However, I wonder wether this is how it should work.

Take a look at this:

(define dlg (instantiate wp-dialog% () (label (text untitled)) (width 
600) (height 600)))
(send dlg show #t)

(define mb (instantiate menu-bar% (dlg)))

==> initialization for menu-bar%: expects argument of type <frame% 
object>; given #<struct:object:wp-dialog%>

That's because wp-dialog% has been exported by a module, but I still 
don't understand why it happens. Right now,

(is-a? dlg frame%)

yields #f but inside its module, wp-dialog% has been defined like

(define wp-dialog%
     (class* frame% () ...
        (super-instantiate ())))

and it also behaves like a frame% as it should, except I can't install 
the menu bar.

What's wrong with it? How can I put GUI classes into modules?

I'd be very happy about some help on this, because I'm afraid I might 
introduce something fundamentally wrong into a large project I'm 
working on.

Thanks,

Erich



Posted on the users mailing list.