On Sat, 6 Jun 2009, Daniel Herring wrote:
I'm using the development code from http://ltk.rplay.net/svn/branches/ltk/repl (r210)
Since tiled Tk dropped the -indicatoron attribute from radio-buttons, I need to define a custom style as described on pages 5-7 of http://tktable.sourceforge.net/tile/tile-tcl2004.pdf
How would one approach this with ltk?
First try was to directly use (send-wish). Then more reading revealed that the Toolbar style was added to all standard ttk themes. So the following just works (bash shell, Tk 8.5 or higher).
# cat << _EOF | wish ttk::checkbutton .cb -text "test" -style Toolbutton ttk::checkbutton .cb2 -text "test2" -style Toolbutton pack .cb pack .cb2 _EOF
However, the ltk equivalent doesn't work...
(defun ltk-toolbar () (with-ltk () (let* ((f (make-instance 'frame)) (cb (make-instance 'check-button :master f :text "test" :variable "cb" :style "Toolbutton")) (cb2 (make-instance 'check-button :master f :text "test2" :variable "cb2" :style "Toolbutton"))) (pack f) (pack cb) (pack cb2))))
Running this gives an error that :style is an invalid parameter. Ok, update (defargs check-button) to include style and recompile ltk.
Now I get the same error I was getting with radio-buttons. "Tcl/Tk error: Layout toolbutton not found" "Do you wish to invoke the debugger?" Y/N
(setf *debug-tk* t) Now I see the problem; the log shows buffer_text "ttk::checkbutton .wc.wd -style toolbutton -textvariable text_wd -variable cb"
"Toolbutton" was downcased to "toolbutton" and the quotes were removed. Looks like a (format s "~A" "Toolbutton") somewhere...
Here's the diffs which make Toolbar-style checkboxes work in ltk for me. I'm not exactly sure what the *initargs* voodoo is, but it seemed to behave rationally.
***** diff --git a/ltk.lisp b/ltk.lisp index aec7b93..b30a0e8 100644 --- a/ltk.lisp +++ b/ltk.lisp @@ -1339,6 +1339,7 @@ can be passed to AFTER-CANCEL" (spacing2 spacing2 "~@[ -spacing2 ~(~a~)~]" spacing2 "") (spacing3 spacing3 "~@[ -spacing3 ~(~a~)~]" spacing3 "") (state state "~@[ -state ~(~a~)~]" state "") + (style style "~@[ -style ~s~]" style "") (tabs tabs "~@[ -tabs ~(~a~)~]" tabs "") (takefocus takefocus "~@[ -takefocus ~(~a~)~]" takefocus "if true, the widget can take the focus") (tearoff tearoff "~@[ -tearoff ~(~a~)~]" tearoff "if true, the menu can be torn off") @@ -1465,7 +1466,7 @@ can be passed to AFTER-CANCEL"
#-:tk84 (defargs check-button () - cbcommand class compound cursor image offvalue onvalue state takefocus textvariable underline variable width) + cbcommand class compound cursor image offvalue onvalue state style takefocus textvariable underline variable width)
#+:tk84 (defargs check-button () *****
Later, Daniel