| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> Perl/TkFAQ-10. ru he shi yong mou ge zu jian lai wan cheng mou ge gong zuo

Perl/TkFAQ-10. ru he shi yong mou ge zu jian lai wan cheng mou ge gong zuo

2008-05-18 21:55:24 编辑來源:互联网 评论
 
 
 
本文为【Perl/TkFAQ-10.如何使用某个组件来完成某个工作】的拼音翻译版
  yuan wen :
  10. How do I get widget X to do Y ?
  There are a number of tasks that can be accomplished with perl/Tk widgets, configurations, and bindings (a few that can't and a few that require specific tricks). Beginners are encouraged to work through the examples in UserGuide.pod. Some examples from UserGuide.pod are addressed in this document among those that follow.
  Basically a widget can be "created" by simply calling the sub of the same name: my $main = new MainWindow;
  will set aside the necessary system memory etc. for a new MainWindow widget (it does not appear until after the MainLoop; call). The object "created" is then callable via the variable $main. So, for example, if you wanted a Button in your MainWindow, then this: $main->Button();
  would be a very basic example of a widget command. If you wanted to later call this button widget you would need a "widget tag or ID" to "get a handle on it". Instead of the above call try something like: my $button = $main->Button();
  The variable $button is how you refer to the Button widget in subsequent calls, such as when we call the pack routine: $button -> pack;
  A complete script that incorporates these ideas to make a very plain button would look like: #!/usr/bin/perl -w use Tk; use strict; my $main = new MainWindow; my $button = $main -> Button(); $button -> pack; MainLoop;
  But who wants such a plain looking button? You can provide a number of different widget configurations via calls to the configure routine as in: #!/usr/bin/perl -w use Tk; use strict; my $main = new MainWindow; my $button = $main->Button(); $button -> configure(-text => 'Press me!'); $button -> pack; MainLoop;
  The Perl motto is "there is more than one way to do it." - perl/Tk remains quite true to this motto as well. Note that the above script could have been written quite succinctly without the use of either the $main or $button variables as: #!/usr/bin/perl -w use Tk; use strict; new MainWindow -> Button(-text => 'Press me!') -> pack; MainLoop;
  But if you want your widgets to actually do things then you must set up callback procedures as discussed later...
  Do not overlook the - sign in front of some options (like -text in the above example) Another commonly overlooked problem is that elements in a hash are supposed to be strings hence a configuration option like -length +> 5, really ought to be specified as either '-length' +> 5, or "-length" +> 5, etc., rather than perl's builtin length() function.
  yi wen :
  10. ru he shi yong mou ge zu jian lai wan cheng mou ge gong zuo ?
  tong guo shi yong Perl/Tk de ge zhong zu jian , bing jin xing bi yao de pei zhi he bang ding , ke yi shi xian hen duo gong neng 。 dang ran , ye you shao shu de yi xie wu fa wan cheng huo xu yao yi ding de ji qiao cai neng wan cheng 。 jian yi chu xue Tk de peng you zai xi de xue xi he shi yong UserGuide.pod zhong de li cheng 。 zai xia mian de jiang jie zhong , wo men ye hui tan dao qi zhong de yi xie li zi 。
  ji ben shang , yao chuang jian yi ge zu jian , zhi xu yao tiao yong he ta ming cheng dui ying de zi cheng xu , li ru :
  my $main = new MainWindow;
  shang mian de yu ju jiang shi Perl jie shi qi wei zhe ge xin de MainWindow zu jian liu chu yi xie bi yao de xi tong nei cun deng zi yuan ( dan shi zhe ge zhu chuang kou bing fei li ke chu xian de , ta yao zhi dao tiao yong MainLoop cai hui chu xian )。 zhe yang , shang mian chuang jian de zhe ge dui xiang , yi hou jiu ke yi tong guo bian liang $main lai tiao yong le 。 li ru , ru guo ni xiang zai ni de zhe ge zhu chuang kou zhong fang zhi yi ge an niu , jiu ke yi zhe yang :
  $main->Button();
  na me , shi xian shang mian de ji ge xiang fa de yi ban “ wan zheng ” de jiao ben ru xia ( zhe li jiang chuang jian yi ge kong bai de an niu ):
  #!/usr/bin/perl -w
  use Tk;
  use strict;
  my $main = new MainWindow;
  my $button = $main -> Button();
  $button -> pack;
  MainLoop;
  dan shi shui hui xiang yao yi ge kong bai de an niu ne ? qi shi , ni ke neng tong guo shi yong configure fang fa dui hen duo bu tong de zu jian jin xing pei zhi 。 li ru :
  #!/usr/bin/perl -w
  use Tk;
  use strict;
  my $main = new MainWindow;
  my $button = $main->Button();
  $button -> configure(-text => 'Press me!');
  $button -> pack;
  MainLoop;
  zhong suo zhou zhi ,Perl de ming yan jiu shi : zuo yi jian shi qing ke yi you duo zhong fang fa 。 suo yi ,Perl/Tk ye tong yang xin shou le zhe yi yuan ze 。 qi shi , shang mian de jiao ben ke yi xie de fei chang jian jie , shen zhi bu shi yong ren he de bian liang ($main he $button), dai ma ru xia :
  #!/usr/bin/perl -w
  use Tk;
  use strict;
  new MainWindow -> Button(-text => 'Press me!') -> pack;
  MainLoop;
  dang ran , ru guo ni que shi xi wang ni de zu jian shi xian yi xie gong neng de hua , ni huan bi xu rang ta men guan lian yi xie dai ma , zhe wo men jiang zai yi hou xiang xi tao lun ……
  zui hou , wo men ti xing da jia bu yao hu lue le zai xuan xiang qian mian de “-” fu hao , li ru shang mian li zi zhong de -text。 ling wai , zhi de yi ti de shi ,hash zhong de yuan su mo ren bei dang zuo zi fu chuan kan dai , suo yi wo men shi yong de pei zhi xuan xiang ru :-length => 5, shi shi shang ying gai xie cheng :’-length’ => 5 huo ”-length” => 5, zhe yang cai ke yi he Perl de nei zhi han shu length() xiang qu bie 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
   yuan wen :   10. How do I get widget X to do Y ?   There are a number of tasks that can be accomplished with perl/Tk widgets, configurations, and bindings (a few that can't and a few that require specific tricks). Beginners are encouraged to work through the examples in UserGuide.pod. Some examples from UserGuide.pod are addressed in this document among those that follow.   Basically a widget can be "created" by simply calling the sub of the same name: my $main = new MainWindow;   will set aside the necessary system memory etc. for a new MainWindow widget (it does not appear until after the MainLoop; call). The object "created" is then callable via the variable $main. So, for example, if you wanted a Button in your MainWindow, then this: $main->Button();   would be a very basic example of a widget command. If you wanted to later call this button widget you would need a "widget tag or ID" to "get a handle on it". Instead of the above call try something like: my $button = $main->Button();   The variable $button is how you refer to the Button widget in subsequent calls, such as when we call the pack routine: $button -> pack;   A complete script that incorporates these ideas to make a very plain button would look like: #!/usr/bin/perl -w use Tk; use strict; my $main = new MainWindow; my $button = $main -> Button(); $button -> pack; MainLoop;   But who wants such a plain looking button? You can provide a number of different widget configurations via calls to the configure routine as in: #!/usr/bin/perl -w use Tk; use strict; my $main = new MainWindow; my $button = $main->Button(); $button -> configure(-text => 'Press me!'); $button -> pack; MainLoop;   The Perl motto is "there is more than one way to do it." - perl/Tk remains quite true to this motto as well. Note that the above script could have been written quite succinctly without the use of either the $main or $button variables as: #!/usr/bin/perl -w use Tk; use strict; new MainWindow -> Button(-text => 'Press me!') -> pack; MainLoop;   But if you want your widgets to actually do things then you must set up callback procedures as discussed later...   Do not overlook the - sign in front of some options (like -text in the above example) Another commonly overlooked problem is that elements in a hash are supposed to be strings hence a configuration option like -length +> 5, really ought to be specified as either '-length' +> 5, or "-length" +> 5, etc., rather than perl's builtin length() function.    yi wen :   10. ru he shi yong mou ge zu jian lai wan cheng mou ge gong zuo ?    tong guo shi yong Perl/Tk de ge zhong zu jian , bing jin xing bi yao de pei zhi he bang ding , ke yi shi xian hen duo gong neng 。 dang ran , ye you shao shu de yi xie wu fa wan cheng huo xu yao yi ding de ji qiao cai neng wan cheng 。 jian yi chu xue Tk de peng you zai xi de xue xi he shi yong UserGuide.pod zhong de li cheng 。 zai xia mian de jiang jie zhong , wo men ye hui tan dao qi zhong de yi xie li zi 。    ji ben shang , yao chuang jian yi ge zu jian , zhi xu yao tiao yong he ta ming cheng dui ying de zi cheng xu , li ru :   my $main = new MainWindow;    shang mian de yu ju jiang shi Perl jie shi qi wei zhe ge xin de MainWindow zu jian liu chu yi xie bi yao de xi tong nei cun deng zi yuan ( dan shi zhe ge zhu chuang kou bing fei li ke chu xian de , ta yao zhi dao tiao yong MainLoop cai hui chu xian )。 zhe yang , shang mian chuang jian de zhe ge dui xiang , yi hou jiu ke yi tong guo bian liang $main lai tiao yong le 。 li ru , ru guo ni xiang zai ni de zhe ge zhu chuang kou zhong fang zhi yi ge an niu , jiu ke yi zhe yang :   $main->Button();    na me , shi xian shang mian de ji ge xiang fa de yi ban “ wan zheng ” de jiao ben ru xia ( zhe li jiang chuang jian yi ge kong bai de an niu ):   #!/usr/bin/perl -w   use Tk;   use strict;   my $main = new MainWindow;   my $button = $main -> Button();   $button -> pack;   MainLoop;    dan shi shui hui xiang yao yi ge kong bai de an niu ne ? qi shi , ni ke neng tong guo shi yong configure fang fa dui hen duo bu tong de zu jian jin xing pei zhi 。 li ru :   #!/usr/bin/perl -w   use Tk;   use strict;   my $main = new MainWindow;   my $button = $main->Button();   $button -> configure(-text => 'Press me!');   $button -> pack;   MainLoop;    zhong suo zhou zhi ,Perl de ming yan jiu shi : zuo yi jian shi qing ke yi you duo zhong fang fa 。 suo yi ,Perl/Tk ye tong yang xin shou le zhe yi yuan ze 。 qi shi , shang mian de jiao ben ke yi xie de fei chang jian jie , shen zhi bu shi yong ren he de bian liang ($main he $button), dai ma ru xia :   #!/usr/bin/perl -w   use Tk;   use strict;   new MainWindow -> Button(-text => 'Press me!') -> pack;   MainLoop;    dang ran , ru guo ni que shi xi wang ni de zu jian shi xian yi xie gong neng de hua , ni huan bi xu rang ta men guan lian yi xie dai ma , zhe wo men jiang zai yi hou xiang xi tao lun ……    zui hou , wo men ti xing da jia bu yao hu lue le zai xuan xiang qian mian de “-” fu hao , li ru shang mian li zi zhong de -text。 ling wai , zhi de yi ti de shi ,hash zhong de yuan su mo ren bei dang zuo zi fu chuan kan dai , suo yi wo men shi yong de pei zhi xuan xiang ru :-length => 5, shi shi shang ying gai xie cheng :’-length’ => 5 huo ”-length” => 5, zhe yang cai ke yi he Perl de nei zhi han shu length() xiang qu bie 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
华丽的模特拍摄(8)
华丽的模特拍摄(7)
华丽的模特拍摄(6)
华丽的模特拍摄(5)
八里沟
朝阳宫
天下峨眉 云上金顶
老家(四)
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有