[ltk-user] Example of scrollbar available?
edgar
edgar-rft at web.de
Fri Dec 13 00:31:10 UTC 2013
Am Fri, 13 Dec 2013 00:13:27 +0100
schrieb Josef Wolf <jw at raven.inka.de>:
> 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.
>
After having a closer look at your code it appears to me that
this is pretty much nonsense what you're trying there.
A listbox widget is meant to manage _text_ items that are
displayed as a vertical list inside the widget.
A listbox widget is *not* meant to contain buttons.
A listbox widget *cannot* scroll buttons.
What exactly are you trying to achive with this code?
Probably we can find a different solution, but I haven't
understood what exactly is the desired purpose.
- edgar
More information about the ltk-user
mailing list