Code Implementation php gtk write text viewer

Source: Internet
Author: User

We will introduce this article 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, 'deststroy '));
  43. $ Cancel_button = $ fs->Cancel_button;
  44. $ Cancel_button->Connect
    ('Clicked', 'fs _ Cancel ');
  45. $ Cancel_button->Connect_object
    ('Clicked', array ($ fs, 'deststroy '));
  46. $ Fs->Show ();
  47. }
  48. $ Window = & new GtkWindow ();
  49. $ Window->Connect (
    'Deststroy', '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. ?>

The above Code describes how to write a text viewer using php gtk.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.