原文:
11.9. How do I get the size of a Canvas? After a re-size? $canvas->cget(-width);
simply returns the size of the canvas when it was created, whereas $canvas->Width;
will get the answer even after a re-size. Substitute [Hh]eight for [Ww]idth in the above if that is what you want.
Nick Ing-Simmons points out that if you want to have your Canvas be able to grow to arbitrarily large sizes be sure to specify the -expand or -fill options when you ->pack the Canvas.
译文:
11.9. 如何获取画布的大小?调整了大小之后呢?
$canvas -> cget(-width);
只返回画布组件在创建时的宽度,而
$canvas -> Width;
则可以获取调整以后的画布大小。如果你需要的是高度数值,只要把上面的[Ww]idth替换成[Hh]eight就可以了。
另外,Nick Ing-Simmons指出,如果你希望你的画布可以延伸到任意大小,那么必须在你使用->pack的时候指定-expand或者-fill选项。