如何让扩展 canvas 填满屏幕的一半以上

How to to have expanding canvas fill more then half the screen

我开始从事一些 GUI 编程工作,并决定使用 ltk。 Ltk 代表 "lisp toolkit",它在基本的 tcl / tk 命令之上提供了一个 lispy 语法层。在某种程度上,它很像 python 的 Tkinter。

然而我发现,当将两个 canvass 放在一个框架中并让其中一个在两个方向上扩展时。 canvas 不会扩展到屏幕的中间点。

为了说明我的意思,我将提供一些图片。 这是创建后的 window。

展开后如下所示:

我现在想去掉浅灰色区域,但是不管怎么弄,左边canvas好像不想进入右半屏

我 运行 在 linux 薄荷上,但这应该没什么大不了的。我使用的是 2-2-2019 发布的 ltk 版本。我试过弄乱当前的关键字参数,但没有任何效果。

这是生成这些屏幕的代码。

(in-package :ltk)

(defun scribble ()
  (with-ltk ()
    (let* ((frame (make-instance 'frame))
           (canvas (make-instance 'canvas
                                  :master frame
                                  :background "white"))
           (color-panel (make-instance 'canvas
                                       :master frame
                                       :width 400
                                       :background "grey")))
      (pack frame
            :expand t
            :fill :both)
      (pack color-panel
            :side :right
            :expand t
            :fill :y
            :anchor :e)
      (pack canvas
            :side :left
            :expand t
            :fill :both
            :anchor :w))))

;; To run the code, just run this function (in REPL or otherwise)
(scribble)

我有点明白了。我仍然不完全确定 tk 是如何工作的,但是从另一个答案中我得到了修复它的信息。

Tcl/Tk: Frames misbehave when resizing.

它进行了轻微的翻译,但删除右侧面板的 :expand 选项设法解决了问题。新代码现在看起来像这样:

(in-package :ltk)

(defun scribble ()
  (with-ltk ()
    (let* ((frame (make-instance 'frame))
           (canvas (make-instance 'canvas
                                  :master frame
                                  :background "white"))
           (color-panel (make-instance 'canvas
                                       :master frame
                                       :width 400
                                       :background "grey")))
      (pack frame
            :expand t
            :fill :both)
      (pack color-panel
            :side :right
            ;; The :expand option has been removed!
            :fill :y
            :anchor :e)
      (pack canvas
            :side :left
            :expand t
            :fill :both
            :anchor :w))))

这解决了所提出的问题。