PHP enters the standalone GUI application arena with PHP-GTK. Learn the basic building blocks of PHP-GTK coding with a tutorial for first installing the language and then building and connecting its widgets, buttons, and functions.
PHP enters the standalone GUI application arena with PHP-GTK. Learn the basic building blocks of PHP-GTK coding with a tutorial for first installing the language and then building and connecting its widgets, buttons, and functions.
whilst very cool, this has been around for a long time…
Version 0.0.1 “Genesis”
1-Mar-2001
first release. (Andrei).
finally version 1.0
i think it has been version 0.5x for about 2 years
i had totally lost hope that it’d every see 1.0 and meanwhile i learned python which offers pygtk, wxpython, pyqt, tkinter, pyobjc, pywin32 etc
however, php still rocks for developing fast scalable web applications.
Seriously it does. I can’t imagine running a graphical web browser written in php. I’m trying to imagine it, but it is difficult.
Version 1.0 has been out since Oct 2003. Rumor has it a 2.x release is in the works with gtk2+ and php5 support. I can’t find much info on this though. Maybe someone reading this has the inside scoop.
Keith
..and thus inappropriate for standalone apps. Though maybe PHP5 will be better for that, dunno..
I just looked at the code for their example hello.php script. Basically it just shows a window with a button, you click the button and “Hello World” comes up. It was like 150 lines !
Though I can see how this could be useful on occasions, I think that there are far better alternatives out there. Maybe in PHP5 this might be worthwhile.
This could be cool for migrating web apps to cross-platform destkop apps. Replace your html forms with GTK widgets and leave the meat of your app alone. I like.
When you need to have separate php installation in order to use PHP-GTK applications then there is not much point building desktop apps with it. How on earth do you distribute those applications to users? Will they jump through the hoops just to get GTK1 looking application working? Not likely. PHP-GTK should at least make self-contained applications.
PHP has its place – a smallish, simple language for cobbling up web apps.
Try doing real programming with it and you will very quickly find out that it is essentially a toy language.
I just looked at the code for their example hello.php script. Basically it just shows a window with a button, you click the button and “Hello World” comes up. It was like 150 lines !
Can you not count? It was only 59 lines of code (including blank lines).
If you want to talk about a language that makes the most of superfluous code, lets talk about Java. 3 lines of code just to open a freaking file, let alone DO anything with it.
Sounds like a Java snob, to me.
PHP is definitly not suited for major desktop programming, but you have to admit, its has its place (and that is far more than …cobbling up web apps.). You can do some serious web-app programming with PHP. But every tool has its use. If you need to do a bunch of text processing, use Perl. If you need a large web based interface, use PHP.
But whatever you do, don’t use Java (unless you like waiting).
Ah, but when will someone come up with PHP-Qt..?!
/dev/null
If your app is going to be for internal use only, where you have control of what software your users have, then you, as an admin, can install the necessary software on all of your users’s machines.
it’s the same line that it wil be in any other scripting language that uses Gtk. Except the stupid angle-bracket stuff
I think that simply Rebol View is much better for small UI apps, network aware. That thingy just looks like a wrapper to some libs, and maybe it is, nothing like View.
btw – while no expert at perl, python, php, isn’t there better option for creating UI with them? – was it Tk?
-pekr-
// Hello in X by Linus Sphinx
// usage: gcc -I/usr/X11R6/include -L/usr/X11R6/lib
// -lXaw -lXt -lXmu -lX11 -lm -o x x.c
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Command.h>
XtAppContext app_context;
Widget toplevel, form, quit_button;
void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
{
XtDestroyApplicationContext (app_context);
exit (0);
}
int main (int argc, char **argv)
{
toplevel = XtOpenApplication (&app_context, “XFirst”, NULL, 0, &argc, argv, NULL, applicationShellWidgetClass, NULL, 0);
form = XtVaCreateManagedWidget (“form”, formWidgetClass, toplevel, NULL);
quit_button = XtVaCreateManagedWidget (“quit_button”, commandWidgetClass, form, XtNlabel, “Quit”, NULL);
XtAddCallback (quit_button, XtNcallback, quit_proc, NULL);
XtRealizeWidget (toplevel);
XtAppMainLoop (app_context);
}
This could be cool for migrating web apps to cross-platform destkop apps. Replace your html forms with GTK widgets and leave the meat of your app alone. I like.
Agreed, but an application needs the stability. GTK isn’t good enough, but PHP5-GTK2 may result in a fairly nice project.
The better solution would be to use XMLFace to generate dynamic SWT (Java) design and funcionality over the internet with PHP as the XML generator.
<?php
// hello.php by Mr PHP
// usage: php4 hello.php
dl(‘php_gtk.’.PHP_SHLIB_SUFFIX);
function delete_event() {
return false;
}
function destroy() {
Gtk::main_quit();
}
function hello() {
global $window;
$window->destroy();
}
$window = &new GtkWindow();
$window->connect(‘destroy’, ‘destroy’);
$window->connect(‘delete-event’, ‘delete_event’);
$button = &new GtkButton(‘Hello!’);
$button->connect(‘clicked’, ‘hello’);
$window->add($button);
$window->show_all();
Gtk::main();
?>
But with Ruby-GNOME2 (which has a subdistribution called Ruby-GTK+2), you can:
–hello1.rb–
require ‘gtk2’
include Gtk
Gtk.init
@w = Window.new
@w.signal_connect(‘delete-event’){ false }
@w.signal_connect(‘destroy’){ Gtk.main_quit }
b = Button.new(“Hello!”)
b.signal_connect(‘clicked’){ @w.destroy }
@w.add b
@w.show_all
Gtk.main
————
But that’s just the beggining, ’cause with little effort you can build an abstraction and get something like this:
–hello2.rb–
require ‘gr/gtk_rules’
GR.app{|w|
b = GR::GRButton.new(“Hello!”)
b.sc{ w.destroy }
w.pack b
}
————-
Anyway, there’s a lot of libraries that PHPers can leverage.
hi, I’m heavily using php-gtk for more than a year now, and i want to say that php-gtk is ready for desktop. It suffer of memory leaks and other stuff ( due to it’s original purpose: run in a webserver).
By the way i use it and it was perfect to create apps my employers required, they were enjoy.
Normally php5 and Gtk2 will correct problem regarding memory (i hope so).
You also can make installer using the nullsoft nsis installer and use priadoblender to pseudo-compile the code, for user there’s no difference with a VB,delphy or other language (only the look is really different and it’s only developper work to do nice theming), ‘bref’ you can’t say that php-gtk isn’t a good things, for php developper they only will have to learn the gtk toolkit to do great things it’s a really good thing for an employer, there’s less learning to perform.
I really hope (it’s only to developpers to do better things) that it will give some idea to others and that we will see some other toolkit working with php, things take time and php is a young language (regardless it’s the third most used at this time) so just be patient and try it before saying it’s a ‘toy’.
If you really think it’s a toy perhaps you need to review your coding method.
well, I’ma faraid that saying it suffers from memory leaks you’re not exactly promoting it.. At least (perl|python|ruby)-gtk do not
OK, so it was “59 lines” – for a Hello World script !
My point was that this is really stretching the usefulness of PHP, and as I said there are much better alternatives out there – like REAL programming languages. There’s very little reasoning in sending a scripting language to do a programming languages’ job.
yes you’re right but i must admit it to be sincere, and i’m ok that’s perl or python doesn’t suffered those problem but they’re older and php wasn’t design for this. dispite this, I maintain that it’s perfect for small enterprise to develop internal tool with a low investment.
It work and is cross-platform without any recompilation or code modification.
(on my own experience the only real problem i’ve encountered was crash when creating and destroying big object with more than hundreds widgets inside)
ps: i don’t want to say that php-gtk is the best or something like that, only that it really has a place