亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1677 | 回復: 0
打印 上一主題 下一主題

請教一個POE+ Gtk2的例子 [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-12-14 19:50 |只看該作者 |倒序瀏覽
POE: Cookbook - Gtk2 Counter Glade
源程序鏈接 http://poe.perl.org/?POE_Cookbook/Gtk2_Counter_glade
glade文件 http://tipi.sf.net/cookbook.glade
  1. #!/usr/bin/perl
  2. # http://poe.perl.org/?POE_Cookbook/Gtk_Interfaces
  3. #
  4. # This sample program creates a very simple Gtk counter.  Its
  5. # interface consists of three widgets: A label, a rapidly increasing
  6. # counter, and a button to reset that counter.
  7. # the 1 - 4 here corresponds to the points in the cookbook entry without
  8. # glade
  9. # 4. Because with POE::Session::GladeXML2, you create the gui through glade
  10. # instead of code, and because it expects all the gtk signal handlers to
  11. # be in a seperate package, it becomes even easier to seperate the GUI
  12. # specific code from the non-gui-dependant code.
  13. package Foo;
  14. use warnings;
  15. use strict;

  16. # POE::Loop::Glib doesn't initialize Gtk2 (for obvious reasons), so we
  17. # do it here
  18. use Gtk2-init;
  19. use POE;
  20. use POE::Session::GladeXML2;

  21. sub new {
  22.   my ($class) = @_;
  23.   my $self = bless {}, $class;
  24.   my $session = POE::Session::GladeXML2->create(
  25.     glade_object => $self,
  26.     glade_file   => 'cookbook.glade',

  27. # 1. You can use the glade_mainwin parameter to create() to tell which
  28. # widget should be considered the main window.
  29.     glade_mainwin => 'window1',
  30.     inline_states => {
  31.       _start   => \&ui_start,
  32.       ev_count => \&ui_count,
  33.     }
  34.   );
  35.   return $self;
  36. }

  37. sub ui_start {
  38.   my ($kernel, $heap) = @_[KERNEL, HEAP];
  39.   $heap->{counter} = 0;
  40.   $kernel->yield("ev_count");
  41. }

  42. # Handle the "ev_count" event by increasing a counter and displaying
  43. # its new value.
  44. sub ui_count {
  45.   my ($session, $kernel, $heap) = @_[SESSION, KERNEL, HEAP];

  46. # 2. When using Gtk2::GladeXML, you can get any widget by name. Thus
  47. # there is no more need to store them yourself.
  48.   my $label = $session->gladexml->get_widget('counter_label');
  49.   $label->set_text(++$heap->{counter});
  50.   $kernel->yield("ev_count");
  51. }

  52. # 3. Instead of having to manually connect gtk signals with poe event
  53. # handlers, POE::Session::GladeXML2 automatically connects the handler
  54. # name you set in glade with the corresponding method in the object you
  55. # pass as glade_object.
  56. sub ui_clear {
  57.   $_[HEAP]->{counter} = 0;
  58. }

  59. package main;
  60. use POE;

  61. # Run the program until it is exited.
  62. my $foo = Foo->new;
  63. $poe_kernel->run();
  64. exit 0;
復制代碼
運行之后 沒報錯 界面上只有一個白塊

拉伸后

時間稍長一點 終止時 會顯示 "Out of memory!"
不知道原因
麻煩 幫我看看 謝謝
Win 7 32 bit, Active Perl 5.10

small.JPG (10.1 KB, 下載次數(shù): 17)

small.JPG
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP