欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

代码实现PHP GTK写文本查看器_PHP教程

程序员文章站 2024-02-01 09:22:16
...
我们在这篇文章中将会为大家介绍

PHP GTK写文本查看器代码示例:

  1. ?php
  2. require_once('File.php');
  3. if (!class_exists('gtk')) {
  4. if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
  5. dl('php_gtk.dll');
  6. else
  7. dl('php_gtk.so');
  8. 10 }
  9. function delete_event()
  10. {
  11. return false;
  12. }
  13. function shutdown()
  14. {
  15. print("Shutting down");
  16. gtk::main_quit();
  17. }
  18. function ButtonLoad_clicked()
  19. {
  20. SelectFile();
  21. }
  22. function ButtonClose_clicked()
  23. {
  24. global $window;
  25. $window->close();
  26. }
  27. function fs_OK($button, $fs)
  28. {
  29. global $TextBox;
  30. $TextBox->insert_text
    (File::readAll($fs-
    >get_filename()), 0);
  31. return true;
  32. }
  33. function fs_Cancel()
  34. {
  35. return false;
  36. }
  37. function SelectFile()
  38. {
  39. $fs = &new GtkFileSelection
    ('Please select the file');
  40. $ok_button = $fs->ok_button;
  41. $ok_button->connect('clicked', 'fs_OK', $fs);
  42. $ok_button->connect_object
    ('clicked', array($fs, 'destroy'));
  43. $cancel_button = $fs->cancel_button;
  44. $cancel_button->connect
    ('clicked', 'fs_Cancel');
  45. $cancel_button->connect_object
    ('clicked', array($fs, 'destroy'));
  46. $fs->show();
  47. }
  48. $window = &new GtkWindow();
  49. $window->connect(
    'destroy', 'shutdown');
  50. $window->connect('delete-event'
    , 'delete_event');
  51. $window->set_border_width(0);
  52. $TextBox = &new GtkText();
  53. $TextBox->set_editable(true);
  54. $ButtonLoad = &new GtkButton('Load');
  55. $ButtonLoad->connect('clicked',
    'ButtonLoad_clicked');
  56. $ButtonClose = &new GtkButton('Close');
  57. $ButtonClose->connect('clicked',
    'ButtonClose_clicked');
  58. $VBox = &new GtkVBox(false, 10);
  59. $VBox->pack_start($ButtonLoad);
  60. $VBox->pack_start($ButtonClose);
  61. $HBox = &new GtkHBox(false, 10);
  62. $HBox->pack_start($TextBox);
  63. $HBox->pack_start($VBox);
  64. $window->add($HBox);
  65. $window->show_all();
  66. gtk::main();
  67. ?>

以上代码就是PHP GTK写文本查看器的相关方法介绍。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446110.htmlTechArticle我们在这篇文章中将会为大家介绍 PHP GTK写文本查看器代码示例: ?php require_once('File.php'); if(!class_exists('gtk')){ if(strtoupper(substr(PHP_OS,0,3)=='W...