[ltk-user] Bold font for label
cage
cage at katamail.com
Mon Jan 16 15:52:28 UTC 2012
On Sun, Jan 15, 2012 at 07:39:53PM +0100, syll-dev at laposte.net wrote:
Hello!
> >
> > Ok, you can query the label for actual font used using the cget function:
> >
> > (cget label "font")
> >
> > Hope this helps.
>
> Not really, unfortunately :( . But thank you for your answer :) . And I didn't know cget, which will be usefull.
>
> If I don't specify the font to use for a label, (cget label "font") returns "".
> If I specify a string as the font to use for a label, (cget label "font") returns this string.
Well, that appear weird to me! Maybe this is the way Tk works.
> So I can't find the font used for "normal" labels. I would like to
> say : "the default font with default properties, but weight=bold". I
> can use :font "Helvetica 10 bold", but not juste :font "bold".
Why do not subclass the label widget?
something like:
(defclass my-label (ltk:label)
())
(defmethod initialize-instance :after ((object my-label) &key (font-name "sans") (font-size 10))
(configure object "font" (format nil "~a ~a" font-name font-size)))
This way cget should always return something meaningful.
Then you can add method to change only the weigth of the font.
This code is not tested of course, no warranty for any purpouse! :)
Bye!
C.
More information about the ltk-user
mailing list