Re: dynamically adding & removing widgets

Hazen Babcock <[email protected]> Wed, 4 Jul 2007 23:44:43 -0400
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
On Jul 4, 2007, at 11:16 PM, Hazen Babcock wrote:

>
> Hello,
>
> I'd like to add/remove widgets from a dialog dynamically. I was
> hoping something like this would work but it does not, i.e "button2"
> is never displayed.
>
> (defun dynamic-test ()
>    (let* ((dialog (make-instance 'dialog
> 				:title "Dynamic Test"
> 				:show-children t))
> 	 (button1 (make-instance 'button
> 				 :label "Button1"))
> 	 (button2 (make-instance 'button
> 				 :label "Button2"))
> 	 (v-box (make-instance 'v-box
> 			       :parent dialog
> 			       :show-children t
> 			       :border-width 5
> 			       :spacing 5
> 			       :child button1)))
>      (signal-connect button1 'clicked #'(lambda ()
> 					 (format t "Adding~%")
> 					 (container-add v-box button2)))
>      (signal-connect button2 'clicked #'(lambda ()
> 					 (format t "Removing~%")
> 					 (container-remove v-box button2)))
>      (dialog-add-button dialog
> 		       "gtk-close"
> 		       #'widget-destroy
> 		       :object t)
>      (dialog-run dialog)))
>
> Suggestions? Do I need to force a redraw? I think this is possible
> with gtk, but maybe not?

I see that you have to use :visible t when you create the button.

Apologies for the noise,
-Hazen


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/