On Do, Dez 12, 2013 at 04:30:47 -0800, Jason Miller wrote:
Your example works fine. But it covers only a single text widget. I am trying to scroll a collection of widgets...
Well, strangely enough, tk doesn't have this as a widget. There are variouls hacks to get it, and it looks like scrolled-frame implements it. However, when setting the master of widgets that go in it, you'll need to use the INTERIOR accessor like so:
(ltk:with-ltk () (let ((sf (make-instance 'ltk:scrolled-frame))) (ltk:pack sf) (loop for i from 1 to 20 for label = (make-instance 'ltk:label :master (ltk:interior sf) :text "Hello, World!") do (ltk:pack label))))
This works great! Thanks Jason!
What is this INTERIOR thing? I've never seen such a thing in Perl/Tk. And the Tk doc's seem to suggest every non-mainwindow is an interior window. But this is about windows, not widgets.
There seems to be still one problem, though: When the root window is resized, the size of the scrolled-frame is not adopted. :expand t :fill :both don't seem to have an effect. The scrolled-frame seems to have a maximum size. Increasing this with the :height and :wide options don't seem to have an effect.
Here's the current code:
(with-ltk () (let* ((root (make-instance 'frame)) (branches (make-instance 'scrolled-frame :master root :height 1000 :width 1000)) (quit-button (make-instance 'button :master root :text "Quit" :command (lambda () (setf *exit-mainloop* t))))) (pack root :side :top) (pack branches :side :top :expand t :fill :both) (pack quit-button :side :top :pady 10)
(loop for i from 1 to 20 for label = (make-instance 'ltk:label :master (ltk:interior branches) :text (format nil "Hello, World ~d!" i)) do (ltk:pack label))
(bind root "<KeyPress-q>" (lambda (ev) (declare (ignore ev)) (exit-wish)))
(do-msg "huhu")))