1

am trying to create a table using a scrolled-treeview, to contain students' performance but i have failed to add the specific columns (name, math-mark, comp-mark) to it.

I have tried the following code but it returns an error

;; test.lisp
(ql:quickload :ltk)
(in-package :ltk)

(with-ltk ()
    (let* ((tree (make-instance 'scrolled-treeview :columns '(0 1 2)) ))
        ; Adding the heading to the column
        (treeview-heading tree 0 "Name") 
        (treeview-heading tree 1 "Math")
        (treeview-heading tree 2 "COMP")
        ; Adding record to the created table.
        (treeview-insert tree :values '("Simon Due" "78" "60"))
        (treeview-insert tree :values '("Kato Ronald" "80" "90"))

        (pack tree)
    )  
)

i expected to return a scrolled-treeview with the two records. Below is the error i get when load test.lisp

Invalid initializattion argument: :columns
in call for class #<STANDARD-CLASS LTK:SCROLLED-TREEVIEW>

2 Answers 2

0

I couldn't find an example with Ltk, but I have one with nodgui.

It appears however than while Ltk has a scrolled treeview, it doesn't support the :columns argument.

The API is:

(make-instance 'scrolled-treeview
               :columns (list "col1" "col2"))

then

(treeview-insert-item tree :text "text" :column-values (list "other" "columns"))

see:

Dev note: I found it simpler to wrap the GUI code in a function, because we can compile the function and get errors and warnings, without running the Tk window and getting an error.

This gives us a simple scrolled treeview:

#++
(ql:quickload :nodgui)

(in-package :nodgui)

(defun run ()
 (with-nodgui ()
    (let* ((tree (make-instance 'scrolled-treeview :columns '("col1" "col2")) ))
      (treeview-insert-item tree :text "one" :column-values (list "two" "three"))
      (pack tree))))

buuuut this creates a table with 3 columns and "col1" is the name of the second one. I'd have to sort this out. I think I got this right in one of my examples. Or, no I didn't, I assumed a treeview always has one column, and I didn't find how to name it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Ehvince, but i had tried-out this particular approach and i realized i had to change the code incredibly.(had to make a lot of changes)
0

This did the work for me.


(ql:quickload :ltk)
(in-package :ltk) 

(with-ltk ()
          (wm-title *tk* "test.lisp")
          (let* ((tree (make-instance 'scrolled-treeview)))

          ;specifies the columns by index(integer) !! not string
          (configure (treeview tree) :columns '(0 1))

          ;specifies the table heading.
          (treeview-heading (treeview tree) "#0" :text "Name" ) ;specifies the initial column of the table
          (treeview-heading (treeview tree) 0 :text "Math")
          (treeview-heading (treeview tree) 1 :text "COMP")

          ;inserts records into the table....
          (treeview-insert (treeview tree) :text '(Kato Samuel) :values (list "89" "80" )) ;this works
          (treeview-insert (treeview tree) :text '(Mary Thereza) :values '("85" "90" )) ;these works too
          (treeview-insert (treeview tree) :text '(Opio Denis) :values '("70" "80" ))

          (grid tree 1 0)
          )
)

However, when it comes to the initial column of the treeview it's "#0" and not 0 as indicated in the configure.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.