| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> Perl/TkFAQ-10.1. ru he shi yong an niu lai tiao yong Perl de zi cheng xu

Perl/TkFAQ-10.1. ru he shi yong an niu lai tiao yong Perl de zi cheng xu

2008-05-18 21:55:23 编辑來源:互联网 评论
 
 
 
本文为【Perl/TkFAQ-10.1.如何使用按钮来调用Perl的子程序】的拼音翻译版
  yuan wen :
  10.1. How do I get a Button to call a Perl subroutine?
  You may specify the -command option in the call to create & pack the button as in: $main->Button(-text => 'Print', -command => sub{do_print($filename, $font)} )->pack;
  Where sub do_print { } is a subroutine that handles two arguments and is declared elsewhere in the script. A full script example of the use of the above code is presented in the second example(s) in UserGuide.pod
  (Full source code for this and other examples from UserGuide.pod may be found at http://www.perltk.org/contrib/pod/. To load code from the web save as a local file say ex1.pl, edit the first line to point to your perl interpreter, then change permission: %chmod u+x ex1.pl, then execute the script: %ex1.pl.)
  The above method is called the "anonymous subroutine (closure)" method. As discussed in Callback.pod one might have re-written that statement to use the "reference to a sub" method thusly: $main->Button(-text => 'Print', -command => [ \&do_print , $filename, $font ] )->pack;
  Note the backslash in front of \&do_print. This causes perl to generate a reference to sub do_print rather than call it. (thanks Jim Stern :-)
  yi wen :
  10.1. ru he shi yong an niu lai tiao yong Perl de zi cheng xu ?
  zai chuang jian he bu zhi an niu de shi hou , ke yi tong guo she ding -command xuan xiang lai zhi ding mou ge zi cheng xu , li ru :
  $main->Button(-text => 'Print',
  -command => sub{do_print($filename, $font)}
  )->pack;
  qi zhong , zi cheng xu do_print{} shi zai jiao ben de qi ta di fang ding yi de , ta ke yi jie shou liang ge shen shu 。UserGuide.pod zhong de di er ge li zi jiu shi shi yong shang mian de dai ma de wan zheng de yang ben 。
  ( yi zhe zhu : you yu yuan wen zhong ti gong de lian jie wu fa shi yong , jian yi da jia zhi jie zai zi ji an zhuang de Tk mu lu zhong zhao jiu ke yi le 。)
  zai shang mian de li zi zhong shi yong le “ ni ming zi cheng xu ”(anonymous subroutine) fang fa 。 gen ju Callback.pod zhong de shuo ming , wo men ke yi yong “ zi cheng xu yin yong ” de fang fa lai gai xie shang mian de yu ju , ru xia :
  $main->Button(-text => 'Print',
  -command => [ \&do_print , $filename, $font ]
  )->pack;
  qing zhu yi , zai \&do_print zhi qian de fan xie gang (\)。 zhe zhong yong fa ke yi shi Perl bu shi tiao yong zhe ge zi cheng xu , er shi chan sheng chu yi ge zhi xiang zi cheng xu do_print de yin yong 。( gan xie Jim Stem)【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

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

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

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

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

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

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

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

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

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

 
 
   yuan wen :   10.1. How do I get a Button to call a Perl subroutine?   You may specify the -command option in the call to create & pack the button as in: $main->Button(-text => 'Print', -command => sub{do_print($filename, $font)} )->pack;   Where sub do_print { } is a subroutine that handles two arguments and is declared elsewhere in the script. A full script example of the use of the above code is presented in the second example(s) in UserGuide.pod   (Full source code for this and other examples from UserGuide.pod may be found at http://www.perltk.org/contrib/pod/. To load code from the web save as a local file say ex1.pl, edit the first line to point to your perl interpreter, then change permission: %chmod u+x ex1.pl, then execute the script: %ex1.pl.)   The above method is called the "anonymous subroutine (closure)" method. As discussed in Callback.pod one might have re-written that statement to use the "reference to a sub" method thusly: $main->Button(-text => 'Print', -command => [ \&do_print , $filename, $font ] )->pack;   Note the backslash in front of \&do_print. This causes perl to generate a reference to sub do_print rather than call it. (thanks Jim Stern :-)    yi wen :   10.1. ru he shi yong an niu lai tiao yong Perl de zi cheng xu ?    zai chuang jian he bu zhi an niu de shi hou , ke yi tong guo she ding -command xuan xiang lai zhi ding mou ge zi cheng xu , li ru :   $main->Button(-text => 'Print',   -command => sub{do_print($filename, $font)}   )->pack;    qi zhong , zi cheng xu do_print{} shi zai jiao ben de qi ta di fang ding yi de , ta ke yi jie shou liang ge shen shu 。UserGuide.pod zhong de di er ge li zi jiu shi shi yong shang mian de dai ma de wan zheng de yang ben 。   ( yi zhe zhu : you yu yuan wen zhong ti gong de lian jie wu fa shi yong , jian yi da jia zhi jie zai zi ji an zhuang de Tk mu lu zhong zhao jiu ke yi le 。)    zai shang mian de li zi zhong shi yong le “ ni ming zi cheng xu ”(anonymous subroutine) fang fa 。 gen ju Callback.pod zhong de shuo ming , wo men ke yi yong “ zi cheng xu yin yong ” de fang fa lai gai xie shang mian de yu ju , ru xia :   $main->Button(-text => 'Print',   -command => [ \&do_print , $filename, $font ]   )->pack;    qing zhu yi , zai \&do_print zhi qian de fan xie gang (\)。 zhe zhong yong fa ke yi shi Perl bu shi tiao yong zhe ge zi cheng xu , er shi chan sheng chu yi ge zhi xiang zi cheng xu do_print de yin yong 。( gan xie Jim Stem)
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
华丽的模特拍摄(8)
华丽的模特拍摄(7)
华丽的模特拍摄(6)
华丽的模特拍摄(5)
八里沟
朝阳宫
天下峨眉 云上金顶
老家(四)
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有