On Do, Dez 12, 2013 at 12:27:59 -0800, Jason Miller wrote:
;First make a textbox and a scrollbar to go with it: (let ((tb (make-instance 'text :width 78 :height 20)) (tbsb (make-instance 'scrollbar :orientation :vertical))) ;Now put them where you want them; I'm using pack as it's the least code: (pack tb :side :left) (pack tbsb :side :left :fill :y) ;Now you need to tell the two widgets about each other (configure tbsb "command" (format nil "~a yview" (widget-path tb))) (configure tb :yscrollcommand (format nil "~a set" (widget-path tbsb))))
Thanks for the hint, Jason! But I am still struggling.
Your example works fine. But it covers only a single text widget. I am trying to scroll a collection of widgets, like this:
(defun scrolltest () (with-ltk () (let* ((root (make-instance 'frame)) (button-list (make-instance 'listbox :master root)) (scrollbar (make-instance 'scrollbar :master root :orientation :vertical)) (quit-button (make-instance 'button :master root :text "Quit" :command (lambda () (setf *exit-mainloop* t)))))
(pack root :side :top) (pack quit-button :side :bottom :pady 10) (pack button-list :side :left) (pack scrollbar :side :left :expand t :fill :y)
(configure scrollbar "command" (format nil "~a yview" (widget-path button-list)))
(configure button-list :yscrollcommand (format nil "~a set" (widget-path scrollbar)))
(dolist (button-number '(1 2 3 4 5 6 7 8 9 0)) (let ((b (make-instance 'button :master button-list :text button-number :command (lambda () (format t "~a~%" button-number))))) (pack b :side :top :anchor :w))))))
The widgets simply don't seem to be connected :-(
I have also tried with a frame instead of a listbox, but frames don't seem to support the yscrollcommand.