Date: Thu, 11 Aug 2005 01:23:45 -0300 From: romildo at uber.com.br To: lablgtk at math.nagoya-u.ac.jp Subject: [newbie] Creating widget classes Message-ID: <20050811042345.GA29721 at malaquias> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello. I am starting to use the lablgtk library and have some basic questions. I have seen some examples of new widget classes defined as in the following example: class my_button ?label ?packing () = let button = GButton.button ?label ?packing () in object (self) inherit GObj.widget button#as_widget method relabel new_label = button#set_label new_label method print = print_string (button#label); print_newline () end If I am not wrong, the button variable introduced by the let binding is common to all instances of the class (class variable). Then if it is changed (with button#set_label, for instance) for an object, it would be changed for all existing objects which are instances of the my_button class. Therefore this class would not work. But it works. I do not understand why. Any explanation? A correct definition would have button as an instance variable: class my_button ?label ?packing () = object (self) val button = GButton.button ?label ?packing () (* ...... *) end but then I do not now how to specify the inheritance on GObj.widget Is the definition of new widget classes discussed somewhere? Romildo