Code implementation of PHP GTK writing text viewer_PHP tutorial

WBOY
Release: 2016-07-15 13:32:53
Original
811 people have browsed it

In this article we will introduce to you

PHP GTK text viewer code example:

  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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!