Perl/TkFAQ-9.Perl/Tk中有哪些类型的组件

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

原文:

9. What widget types are available under perl/Tk?

The following Tk widget primitives are available under perl/Tk:

Button

Canvas

Checkbutton

Entry

Frame

Label

Listbox

Menu

Menubutton

Message

Radiobutton

Scale

Scrollbar

Text

Toplevel

The following are Tix widget primitives available under perl/Tk:

HList

InputOnly

There are (a lot of) other [compound|composite|constructs] available too. You can also synthesize new widgets out of these primitives using perl5's object-oriented multiple inheritance features. You can even build entirely new widget primitives from raw C (XS) code then use and re-use that. (Perl 5 is extremely configurable.)

A good introduction to the primitives and how they may be used in conjunction with each other may be found in the widget demo script. Note that all the widget demos have a "Show Code" button. To help figure out what is happening in the script you may, when the window appears, edit the text and instrument the code with print statements and then simply press "Rerun Demo". Another place to see examples of the primitives (on the web) is at the image supplement to this FAQ at the following URL:

http://www.perltk.org/contrib/ptkIMG.html

译文:

9. Perl/Tk中有哪些类型的组件?

Perl/Tk中的基本组件包括以下类型:

l Button

l Canvas

l Checkbutton

l Entry

l Frame

l Label

l Listbox

l Menu

l Menubutton

l Message

l Radiobutton

l Scale

l Scrollbar

l Text

l Toplevel

另外,还有几种复合的组件

l Hlist

l InputOnly

(译者注:初学Tk的朋友要了解以上组件的外观,可以看这里:http://www.perlchina.net/cgi-bin/gforum/gforum.cgi?post=4628#4628)

同时,还有很多其它的(混合的,复合的或新构建的)。并且,利用Perl5面向对象编程的可遗传性质,你完全可以自己用这些基本的组件构建出新的综合组件。甚至,你还可以使用原始C语言代码构建出全新的组件,然后重复的使用它(Perl5是具有极强的可塑性的)。

其实,组件的演示脚本(译者注:在命令行中键入widget)就是对这些基本组件的用法、以及它们如何联合使用等问题的很好的介绍说明。请注意,所有的组件演示程序都有一个“Show Code”(显示代码)的按钮。你可以在阅读了它们的原始代码以后,在那个窗口中直接修改,并且只要简单的再点击一下“Rerun Demo”的按钮就可以立刻看到你修改后的效果了。

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