Perl/TkFAQ-11.9.如何获取画布的大小?调整了大小之后呢?

王朝perl·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

原文:

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选项。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航