PHP-GTK: Splash窗口例子

jackxiang 2010-10-7 11:07 | |

  <?php
  class splash {
   var $gui = null;
   var $times = null;
   function splash() {
   $this->gui = array(); // 初始化
   $this->times = 0;
   }
   /**
   * 运行主程序
   */
   function run() {
   $this->gui['splash'] = &new GtkWindow(GTK_WINDOW_POPUP);
   $this->gui['splash']->set_position(GTK_WIN_POS_CENTER);
   $this->gui['splash']->set_usize(365, 221);
   $this->gui['vbox'] = &new GtkVbox(false, 0);
   // load pixmap
   list($pixmap, $mask) = Gdk::pixmap_create_from_xpm($this->gui['splash']->window, null, 'splash.xpm');
   $splash = &new GtkPixmap($pixmap, $mask);
  
   // add the image to the box
   $this->gui['vbox']->add($splash);
  
   // load loading label
   $this->gui['loading'] = &new GtkLabel();
   // add the loading label to the box
   $this->gui['vbox']->add($this->gui['loading']);
   // add the box to the window
   $this->gui['splash']->add($this->gui['vbox']);
   $this->gui['splash']->show_all();
   $this->loading();
   Gtk::main();
   }
  
   /**
   * Loging ...
   */
   function loading() {
   $this->times ++;
   $this->gui['loading']->set_text('Loading .' . str_repeat('.', $this->times));
   // 刷新屏幕
   while (gtk::events_pending()) gtk::main_iteration();
   $loadingid = Gtk::timeout_add(1000, array(&$this, 'loading'));
   // 运行4次退出
   if($this->times > 4) {
   Gtk::main_quit();
   Gtk::timeout_remove($loadingid);
   }
   }
  }
  $splash = &new splash();
  $splash->run();
  ?>

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3610/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]