PHP-GTK 2
Im a big Fan of PHP and one day i wanted to make a desktop application that could pull down posts and private messages from one of my forums. I didn’t want to learn a whole new language, just code the small application so i dismissed C, and looked at Python. I saw there was PyGTK, saw i wondered if there were PHP-GTK, which indeed there is.
I bought Scott Mattock’s PHP-GTK 2 book (Only to learn later that it was based on one of the early alphas) and dove straight in. Installation wasn’t hard, and i could get started straight away. I learned the hello world example first, and here it is..
-
<?php
-
-
$wnd = new GtkWindow();
-
$wnd->set_title(‘Hello world’);
-
-
$lblHello = new GtkLabel("Just wanted to say\r\n‘Hello world!’");
-
$wnd->add($lblHello);
-
-
$wnd->show_all();
-
Gtk::main();
-
?>
As you can see, the syntax is OOP. If you’ve coded GTK, or PyGTK before things will look very similar. We start off by declaring a new GtkWindow() and assign it to the class/variable $wnd. We then set a title using set_title. The next line makes sure the window shuts correctly (destroys) it when you close the window, it will also stop the gtk main loop. Then we declare a new GtkLabel and give it some text, and then add it to the window, again fairly self explanitory. We then tell the window to show and declare the Gtk Main loop (which keeps the window open).











Michael Says:
Cool
But how does it look like?
Posted on April 30th, 2008 at 12:15 pm
Panzer Says:
Ive uploaded a thumbnail there, click it to see the full thing.
Posted on April 30th, 2008 at 1:50 pm
Michael Says:
Thanks, looks cool, but I hope there is a way to remove the command prompt window
Posted on May 1st, 2008 at 5:08 am
Panzer Says:
Yeah, if you compile the application into an exe/binary, it removes it.
Posted on May 1st, 2008 at 3:04 pm