LTK button height not configurable

2019-07-25 16:30发布

问题:

I'm using LTK for basic windows in Common Lisp. I want to create a square button, but it turns out that height can't be changed. Here's the relevant part of the code:

(let ((tile (make-instance 'button
                           :width 20
                           :height 20))))

I'm getting an error:

Invalid initialization argument:
  :HEIGHT
in call for class #<STANDARD-CLASS LTK:BUTTON>.
See also:
  The ANSI Standard, Section 7.1.2
  [Condition of type INITARG-ERROR]

In the LTK documentation, height is listed as configurable for buttons. Is there something wrong with the installation or is it a known bug or what?

回答1:

I think it is missing on ltk side. With M-. in Slime I go to the definition of button:

(defargs button (widget)
  command
  compound
  default
  image
  state
  textvariable
  underline
  width)

There is no height indeed and it doesn't come from widget.

I asked on nodgui (ltk fork with syntax sugar and more meta-widgets) because the maintainer is real nice: https://notabug.org/cage/nodgui/issues/6

His answer:


nodgui supports only the widget that use 'ttk' theme engine:

https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_intro.htm

the documentation for ttk::button:

https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_button.htm

shows no height parameter (correct me if I am wrong)

(is there a chance that you are looking at https://www.tcl.tk/man/tcl8.6/TkCmd/button.htm ? This is the non-ttk version of the widget and is not supported)

Probably you can play with frame and sticky attribute to modify the geometry of a button (never tried), moreover I do not know about a way to specify the size of a button in pixel units.

Hope this helps someway! :)

ps: Probably is important to point out that the LTK documentation is outdated in the widget part.


Other information to consider: https://mailman.common-lisp.net/pipermail/ltk-user/2016-June/000625.html

Tcl/Tk up to 8.4 including allowed the font for buttons to be set. From 8.5 there was the ttk widget set, which at some point became the default for ltk. The ttk widget set uses a theme engine to determine many of the rendering parameters for widgets to achieve a "native" look. This means that a lot of older options for the widgets got removed. You can find the documentation for the widget here: https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_button.htm

If you push :tk84 onto features, you get the old style widgets, otherwise you can of course create/modify ttk themes, that should give you the ability to configure fonts too. With bug reports like this, it also would be very helpful if you included information about the operation system the problem shows, the lisp you are using Ltk with, and in this case, a screen shot.



回答2:

Configuring is done through the configure function according to ch. 3.14 of the documentation.