[cells-gtk-devel] Editable Table

Peter Hildebrandt peter.hildebrandt at gmail.com
Tue Oct 6 19:52:46 UTC 2009


Hi Martin,

This should be possible--and as a matter of fact I used similar
functionality in my MSc project.  I had a table in which I could enter
numbers, symbols, and even functions (which--using cells--got compiled in
real time like this:   (compiled-fn :initform (c?  (compile ^fn)))    )

I will try to locate the code later (unfortunately I am on a business trip
right now, but I might find it somewhere anyways ...)

Best
Peter

PS.  We're seeing a lot of traffic (comparably) on this list lately.  It's
great to see people actually using cells-gtk.

On Tue, Oct 6, 2009 at 8:37 PM, Martin Kielhorn <
kielhorn.martin at googlemail.com> wrote:

> Hi,
> I want a table with numbers and when I click on one number I want to change
> it to
> a new value. I managed to copy the table from test-gtk/test-tree-view.lisp
> and I added
> :editable t to the def-columns call. I can edit the number, but the system
> doesn't store
> the value back into one of my variables, e.g. (position$ (nth 2 *items*)).
> So when I press
> enter after the edit, the old value will be shown again.
>
> I hoped the :on-edit slot of listbox could be used for this task but the
> format is never executed.
>
> Or is it only possible to do it like in the Cells-Tree-View example?
> It seemed quite complicated to me, as I don't want two copies of branched
> trees.
> I think that is the next thing I would be glad to hear how :on-edit is to
> be used.
>
> [I run the following code in sbcl with threads.]
>
> (require :asdf)
> (require :cells-gtk)
>
> (defpackage :mk
>   (:use :cells :cl :cells-gtk))
>
> (in-package :mk)
>
> (defmodel myapp (gtk-app)
>   ()
>   (:default-initargs :width 400 :height 300
>              :md-name :mk-top
>              :kids (c-in nil)))
> (init-gtk)
> (start-win 'myapp)
>
> (defmodel listbox-test-item ()
>   ((position  :accessor position$  :initarg :position  :initform nil)
>    (curvature :accessor curvature$ :initarg :curvature :initform nil)))
>
> (defparameter *items*
>   (list (make-be 'listbox-test-item
>              :position  (coerce (random 20) 'double-float)
>              :curvature (coerce (random 20) 'double-float))
>     (make-be 'listbox-test-item
>              :position  (coerce (random 20) 'double-float)
>              :curvature (coerce (random 20) 'double-float))))
>
> (let ((top (find-widget :mk-top)))
>   (setf
>    (kids top)
>    (list
>     (mk-vbox
>      :fm-parent top
>      :kids
>      (kids-list?
>       (mk-listbox :md-name :listbox
>           :selection-mode :single
>           :columns (def-columns
>                 (:double (:title "Position") (lambda (node) '(:editable
> t)))
>                 (:double (:title "Curvature")))
>           :items *items*
>           :print-fn (lambda (item)
>                   (list (position$ item)
>                     (curvature$ item)))
>           :on-edit (lambda (node col new-val)
>                  (format t "~a~%" (list node col new-val)))))))))
>
>
> Regards, Martin
> --
> Martin Kielhorn
> Randall Division of Cell & Molecular Biophysics
> King's College London, New Hunt's House
> Guy's Campus, London SE1 1UL, U.K.
> tel: +44 (0) 207 848 6519,  fax: +44 (0) 207 848 6435
>
> _______________________________________________
> cells-gtk-devel site list
> cells-gtk-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cells-gtk-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cells-gtk-devel/attachments/20091006/b27d3c27/attachment.html>


More information about the cells-gtk-devel mailing list