[ltk-user] problem with the :background keyword

Peter Herth herth at peter-herth.de
Sat Sep 1 12:17:00 UTC 2012


Hi,

short answer: you do nothing wrong, you can't set the background of buttons.

Long answer: Tk introduced a new set of widgets in 8.5, the "Ttk"
versions, which are fully themeable and tend to look native on most
platforms. Ltk by default uses those widgets. As they are based on an
UI theme, they support less configuration options. And frankly
speaking, it is a good practice not to change e.g. the background of
buttons. The only widget, where I needed to change the background
frequently would be the frame widget - and for that reason Ltk wraps
the "classical-frame" which is the old style one with a background
option. You could of course define your own UI theme Tk and Ltk allows
for that.

Peter

On Sat, Sep 1, 2012 at 3:19 AM,  <harven at free.fr> wrote:
> Hi,
>
> I am a beginner at both ltk and tk and I am trying to convert a small programme
> from Tk to LTk.
>
> Tk version:
> pack [button .b -text "Push Me" -background red -command {tk_messageBox -message "hello, world"}]
>
> LTk version:
> (with-ltk ()
>   (let ((my-button
>          (make-instance 'text :text "Push Me"
>                         :background :red
>                         :command
>                         (lambda () (message-box "Hello, world!" "message"
>                                                 'ok 'info)))))
>     (pack my-button)))
>
> The Tk version works fine, whereas the LTk version gives the following error:
>
>   Invalid initialization argument:
>     :BACKGROUND
>   in call for class #<STANDARD-CLASS BUTTON>.
>   See also:
>     The ANSI Standard, Section 7.1.2
>     [Condition of type INITARG-ERROR]
>
> On the other hand, there is no error if the :background line is removed.
> It's as if the :background keyword is only allowed for a few specific widgets,
> like the text widget. I also get errors if I try to set it with configure,
> as shown in the LTk manual, e.g. (configure my-button :background :blue)
>
> What am I doing wrong ?
>
> Any help is appreciated, I am using tk8.5 on debian squeeze, with sbcl 1.0.55,
> and the current release of ltk that ships with quicklisp.
> Sincerely,
> --
> harven
>
> _______________________________________________
> ltk-user site list
> ltk-user at common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user




More information about the ltk-user mailing list