php-gtk

Thread Solved
Reply

Join Date: Sep 2007
Posts: 1,336
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 126
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

php-gtk

 
0
  #1
Dec 6th, 2008
I have just started learning php-gtk 2 but am a bit stuck. First is that are there any php-gtk 2 debuggers or error loggers that I can use because at the moment, if there is a bug in my script, the exported exe file made from my php-gtk script is simply currupted or won't open. So does any body know of such program to read my script and tell if there are bugs and what roughly lines the bugs are on. Note: This is php-gtk - not plain php.

Also I have encountered a multi object problem where only the first button will be displayed on the screen. Below is the code I am using and do you know why the button $button2 wont show.

  1. <?php
  2.  
  3. function pressed()
  4. {
  5. echo "Hello again - The button was pressed!\n";
  6. }
  7.  
  8. function pressed2()
  9. {
  10. echo "Hello again - The button was pressed!\n";
  11. }
  12.  
  13.  
  14. $window = new GtkWindow();
  15.  
  16. $window->resize(800,600);
  17. $window->set_title('My Diary');
  18. $window->connect_simple('destroy', array('Gtk', 'main_quit'));
  19.  
  20.  
  21. $button1 = new GtkButton('Jan');
  22. $button1->connect_simple('clicked', 'pressed');
  23. $button1parrent = new GtkAlignment(0, 0, 0.01, 0.01);
  24. $button1parrent->add($button1);
  25. $window->add($button1parrent);
  26.  
  27.  
  28.  
  29. $button2 = new GtkButton('February');
  30. $button2->connect_simple('clicked', 'pressed2');
  31. $button2parrent = new GtkAlignment(0, 0, 0.01, 0.01);
  32. $button2parrent->add($button2);
  33. $window->add($button2parrent);
  34.  
  35.  
  36. $window->show_all();
  37. //$window->set_resizable(false);
  38. Gtk::main();
  39.  
  40. ?>
In case if you are wondering what php-gtk is, it is like php but with more libraries/binaries and instead of creating webpages, it creates programs.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: php-gtk

 
0
  #2
Dec 6th, 2008
I've fixed your code:

  1. <?php
  2.  
  3. if (!class_exists('gtk')) {
  4. die("Please load the php-gtk2 module in your php.ini\r\n");
  5. }
  6.  
  7. function pressed()
  8. {
  9. echo "Hello again - The button was pressed!\n";
  10. }
  11.  
  12. function pressed2()
  13. {
  14. echo "Hello again - The button was pressed!\n";
  15. }
  16.  
  17.  
  18. $window = new GtkWindow();
  19.  
  20. $window->resize(800,600);
  21. $window->set_title('My Diary');
  22. $window->connect_simple('destroy', array('Gtk', 'main_quit'));
  23.  
  24.  
  25. $button1 = new GtkButton('Jan');
  26. $button1->connect_simple('clicked', 'pressed');
  27. $button1parrent = new GtkAlignment(0, 0, 0.01, 0.01);
  28. $button1parrent->add($button1);
  29.  
  30.  
  31.  
  32. $button2 = new GtkButton('February');
  33. $button2->connect_simple('clicked', 'pressed2');
  34. $button2parrent = new GtkAlignment(0, 0, 0.01, 0.01);
  35. $button2parrent->add($button2);
  36.  
  37.  
  38. $buttonbox = new GtkVButtonBox(); // or GtkHButtonBox for horizontal placement
  39. $buttonbox->add($button1parrent);
  40. $buttonbox->add($button2parrent);
  41.  
  42.  
  43. $window->add($buttonbox);
  44.  
  45. $window->show_all();
  46. //$window->set_resizable(false);
  47. Gtk::main();
  48.  
  49.  
  50. ?>

I'm learning php-gtk too It seems like is mandatory to enclose UI elements into boxes before adding to GtkWindow.

I recommend to read this serie of tutorials:

http://gtk.php.net/manual/en/tutorials.packing.php
Last edited by martin5211; Dec 6th, 2008 at 8:52 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,336
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 126
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: php-gtk

 
0
  #3
Dec 7th, 2008
Yes, It works.
Thanks. My current code is below and displays a row of buttons at the top. The only other thing I need to know is if there is any software that will display the error messages from any errors in my php file. I have tried enabling error reporting in the php.ini file of the compilation but makes no difference but other than that it works great and love the tutorials you linked to.

Below code does the job:

  1. <?php
  2.  
  3. if (!class_exists('gtk')) {
  4. die("Please load the php-gtk2 module in your php.ini\r\n");
  5. }
  6.  
  7. function pressed()
  8. {
  9. echo "Hello again - The button was pressed!\n";
  10. }
  11.  
  12. function pressed2()
  13. {
  14. echo "Hello again - The button was pressed!\n";
  15. }
  16.  
  17.  
  18. $window = new GtkWindow();
  19.  
  20. $window->resize(800,600);
  21. $window->set_title('My Diary');
  22. $window->connect_simple('destroy', array('Gtk', 'main_quit'));
  23.  
  24.  
  25. $button1 = new GtkButton('January');
  26. $button1->connect_simple('clicked', 'pressed');
  27.  
  28. $button2 = new GtkButton('February');
  29. $button2->connect_simple('clicked', 'pressed2');
  30.  
  31. $button3 = new GtkButton('March');
  32. $button3->connect_simple('clicked', 'pressed2');
  33.  
  34. $button4 = new GtkButton('April');
  35. $button4->connect_simple('clicked', 'pressed2');
  36.  
  37. $button5 = new GtkButton('May');
  38. $button5->connect_simple('clicked', 'pressed2');
  39.  
  40. $button6 = new GtkButton('June');
  41. $button6->connect_simple('clicked', 'pressed2');
  42.  
  43. $button7 = new GtkButton('July');
  44. $button7->connect_simple('clicked', 'pressed2');
  45.  
  46. $button8 = new GtkButton('August');
  47. $button8->connect_simple('clicked', 'pressed2');
  48.  
  49. $button9 = new GtkButton('September');
  50. $button9->connect_simple('clicked', 'pressed2');
  51.  
  52. $button10 = new GtkButton('October');
  53. $button10->connect_simple('clicked', 'pressed2');
  54.  
  55. $button11 = new GtkButton('November');
  56. $button11->connect_simple('clicked', 'pressed2');
  57.  
  58. $button12 = new GtkButton('December');
  59. $button12->connect_simple('clicked', 'pressed2');
  60.  
  61.  
  62. $buttonbox = new GtkHButtonBox(); // or GtkHButtonBox for horizontal placement
  63. $buttonbox->add($button1);
  64. $buttonbox->add($button2);
  65. $buttonbox->add($button3);
  66. $buttonbox->add($button4);
  67. $buttonbox->add($button5);
  68. $buttonbox->add($button6);
  69. $buttonbox->add($button7);
  70. $buttonbox->add($button8);
  71. $buttonbox->add($button9);
  72. $buttonbox->add($button10);
  73. $buttonbox->add($button11);
  74. $buttonbox->add($button12);
  75. $buttonboxparrent = new GtkAlignment(0, 0, 0.01, 0.01);
  76. $buttonboxparrent->add($buttonbox);
  77.  
  78.  
  79. $window->add($buttonboxparrent);
  80.  
  81. $window->show_all();
  82. //$window->set_resizable(false);
  83. Gtk::main();
  84. ?>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: php-gtk

 
0
  #4
Dec 7th, 2008
I'm using the php executable from Terminal to load the php-gtk code (located in /usr/local/php-gtk in my Mac OS 10.5 after installing this DMG package).

Before compiling the code you can perform php -l code_example.php to check for syntax errors (maybe, we can do it automatically from the editor assigning a macro or menu function). In Windows should work exactly as described here, also it's possible to perform and interpret the code, showing errors and output messages on the MS-DOS prompt using directly php code_example.php alone without -l parameter.
Last edited by martin5211; Dec 7th, 2008 at 2:43 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,336
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 126
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: php-gtk

 
0
  #5
Dec 8th, 2008
Originally Posted by martin5211
I'm using the php executable from Terminal to load the php-gtk code (located in /usr/local/php-gtk in my Mac OS 10.5 after installing this DMG package).
Thanks for the advice and it is the information in that statement that allowed me to find out how to run the debugger. And since I have 2 computers, instead of installing the official software twice (I like the unofficial stuff) I simply just copied the 2 files (php.exe and php5ts.dll) from the computer with the official software to a selected directory in the computer without the official software where I could use a batch file to do the hard work. I then placed in my batch file the below commands and it works like a charm.
  1. @echo -
  2. @php -l index.php
  3. @echo -------------------------------
  4. @pause
Pitty this isn't obvious to find on the internet.
So *Solved*
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: php-gtk

 
0
  #6
Dec 8th, 2008
Also, this modification can be useful adding an argument to the ms-dos, avoiding copy&paste each file name:

  1. @echo off
  2. echo -
  3. php -l %1
  4. echo -------
  5. pause
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC