Date: Thu, 11 Aug 2005 09:02:46 -0300 From: romildo at uber.com.br To: lablgtk at math.nagoya-u.ac.jp Subject: How to define a customized button Message-ID: <20050811120246.GA10175 at malaquias> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello. I want to learn how to define customized widgets with lablgtk. For that I would like to define a new button widget which just automatically encloses its text label inside square brackets. Attached is my attempt in doing so. But it does not compile. As I did not find any explanation on how to define customized widgets, I am lost on how to do it. Maybe someone kind enough could show me how to implement this simple program. Romildo --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test1.ml" (* test1.ml *) class my_button ?label ?packing ?show () = let button = let my_label = match label with None -> "" | Some str -> str in GButton.button ~label:("[" ^ my_label ^ "]") ?packing ?show () in object (self) inherit GButton.button button method set_label new_label = button#set_label ("[" ^ new_label ^ "]") method print = print_string (button#label); print_newline () end let test button new_label = button#print; button#set_label new_label; button#print; print_newline () let main () = let win = GWindow.window ~title:"Test" ~border_width:10 () in let but = new my_button ~label:"Testing" ~packing:win#add () in but1#connect#clicked ~callback:(test but "Tested"); win#connect#destroy ~callback:GMain.Main.quit; win#show (); GMain.Main.main () let _ = Printexc.print main () --huq684BweRXVnRxX--