To: lablgtk at kaba.or.jp Subject: Re: changing the text of a button ? From: Remi Vanicat Date: Thu, 09 Oct 2003 14:09:17 +0200 In-Reply-To: Sven Luther's message of "(unknown date)" Message-ID: <87n0caipea.dlv at wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Sender: Vanicat Remi Sven Luther writes: > Hello, > > I would like to change the text of a button, but have difficulties doing > this. > > It seems to me that the button is a container, which contains a label as > only child, and thus i tried to do this : > > let text = ((List.hd suite#children) :> GMisc.label) in > text#set_text "Foo" Ttt, a container contain widget, and if you can transform a label into a widget with coercion, you can do the converse (by the way, I really have to learn which one is upcast, and which one is downcast). One way of doing it is : let label_aswidget = (List.hd suite#children)#as_widget in let gtklabel = GtkMisc.Label.cast label_aswidget in let text = new GMisc.label gtklabel in text#set_text "Foo" > But naturally, it didn't seem to work, claiming that the children widget > had no method connect or something such. > > Any hint on doing so, or maybe a set_text method could be added to the > button object ? It would not be a good idea if the object contain something else than a label.... -- Rémi Vanicat remi.vanicat@laposte.net