TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-01-2008, 05:40 PM   #1 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default PHP-GTK2 (finally) Released

Well, the PHP-Gtk team proved me wrong by finally releasing PHP-Gtk2. And to think I'd assumed that the project was dead

PHP-Gtk2 brings lots of improvments over the previous version, including much better window drawing / handling on Windows.

Some useful links for anyone interested:

PHP-Gtk Website
PHP-Gtk2 Documentation
PHP-Gtk2 Downloads

I've also knocked up a little demo app for anyone interested in PHP-Gtk - code and screenshots below:

Code:

PHP Code:
<?php
// ===============================================================
// PHP-GTK2 Demo Application
// Accepts input from a text box then shows a popup message
// ---------------------------------------------------------------
// Written by Alan Wagstaff
// Donated to the Public Domain
// ===============================================================

// Check if GTK2 is loaded
if( !class_exists('gtk'))
{
    die(
'Please load the php-gtk2 module in your php.ini' "\r\n");
}

/**
 * Main Window
 * Displays a label, input box and button
  */
class windowMain extends GtkWindow
{

    
/**
     * Text input
     *
     * @var object
     */
    
var $txtName null;
    
    
/**
     * Constructor - sets up the main window
     */
    
function __construct()
    {

        
parent::__construct();
        
        
// Create the window
        
$this->connect_simple('destroy', array('gtk''main_quit'));

        
// Set the window properties
        
$this->set_title('TalkPHP PHP-GTK2 Demo');
        
$this->set_position(Gtk::WIN_POS_CENTER);
        
$this->set_border_width(8);
        
        
// Add the label, input box and go button
        
$this->add($this->createInput());
        
        
// Display the window
        
$this->show_all();

    }

    
/**
     * Creates the label, input box and button elements
     */
    
function createInput()
    {
        
        
// Create a panel that will hold our other elements
        
$panel = new GtkVBox(false8);
        
        
// Create the input box
        
$this->txtName = new GtkEntry();
        
        
// Create the label
        
$labelNamePrompt = new GtkLabel('Please Enter Your _Name');
        
$labelNamePrompt->set_use_underline(true);
        
$labelNamePrompt->set_mnemonic_widget($this->txtName);
        
        
// Create the button
        
$btnGo = new GtkButton('Go!');
        
        
// Connect the click event of the button to our function btnGo_clicked()
        
$btnGo->connect('clicked', array($this'btnGo_clicked'));
        
        
// Add all our elements to the container panel - just shoves them in starting at the top
        
$panel->pack_start($labelNamePromptfalsetrue);
        
$panel->pack_start($this->txtNamefalsetrue);
        
$panel->pack_start($btnGofalsetrue);
        
        
// Return our element-filled panel
        
return $panel;
        
    }

    
/**
     * Fires when the Go button is clicked
     */
    
function btnGo_clicked($btnGo)
    {

        
// Create a dialog box with the following options:
        // DIALOG_MODAL - The applicaiton cannot be used while the dialog is open
        // DIALOG_DESTORY_WITH_PARENT - Close when the app closes
        // MESSAGE_INFO - The icon to display
        // BUTTONS_OK - The buttons to display
        // The text that will appear in our dialog box
        
$dlgHello = new GtkMessageDialog($this,
            
Gtk::DIALOG_MODAL Gtk::DIALOG_DESTROY_WITH_PARENT,
            
Gtk::MESSAGE_INFO,
            
Gtk::BUTTONS_OK,
            
sprintf('Hello %s, from everyone at TalkPHP!'$this->txtName->get_text())
        );
        
        
// Show the dialog box until it is closed
        
$dlgHello->run();
        
        
// Destroy the dialog box
        
$dlgHello->destroy();

    }

}
    
// ----------------
// Create our new Window (aka, application)
// ----------------
new windowMain();

// ----------------
// Run our application
// ----------------
Gtk::main();
All the application does is prompt the user for their name then display it in a popup dialog box.

Screenshots:





I still wouldn't recommend using PHP-Gtk2 for creating full Windows / Linux applications but it is definately an improvment on the previous versions

Alan
Attached Thumbnails
php-gtk2-finally-released-main_window.jpg  php-gtk2-finally-released-dialog_popup.jpg  
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following 3 Users Say Thank You to Alan @ CIT For This Useful Post:
obolus (03-01-2008), ReSpawN (03-01-2008), SOCK (03-01-2008)
Old 03-01-2008, 05:47 PM   #2 (permalink)
The Acquainted
 
Join Date: Nov 2007
Posts: 154
Thanks: 31
SOCK is on a distinguished road
Default

Thanks for that, nice example. I haven't used or even looked at PHP-GTK in years, I'd assumed production was dead as well.
__________________
I reject your reality, and substitute my own.
SOCK is offline  
Reply With Quote
Old 03-01-2008, 08:55 PM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Wow, that looks seriously very awesome. Yet it is still kinda new so I think if you implement is, in what ever, you'll be the first. Is there a tie to a particular PHP version like PHP 5 (since OOP is 'completed' in 5)?
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-01-2008, 09:16 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

The PHP-Gtk2 package is completely self-contained. It comes with a specially-configured CLI version of PHP 5.2.5 and doesn't require a webserver to run.

To run an application, you would just drop to a command line and use:

Code:
Linux: ./php myApp.php
Windows: php.exe myApp.php
Which then starts up the windows like the ones shown in the screenshots above.

Attached is the php.ini that comes with it and the results of php.exe -i for anyone interested

Alan
Attached Files
File Type: txt phpinfo.txt (15.9 KB, 186 views)
File Type: txt php-cli.ini.txt (2.5 KB, 170 views)
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
ReSpawN (03-01-2008)
Old 03-01-2008, 09:19 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

So (not that I have) it doesn't run with PHP 4.4.8 or what ever. Since some of my customers are still deepening on my skills to script 4.4.8.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-01-2008, 09:23 PM   #6 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

It wouldn't effect them Because it is completely self-contained, you distribute the PHP-Gtk2 folder (including php.exe) with your PHP files. Your customers wouldn't have to install anything or adjust anything on their existing php4 / web server setup as it doesn't use it.

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-01-2008, 09:24 PM   #7 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

Wait those are windows windows?? I mean it is not executed in browser ??
Thats freaky freaking awesome :D
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-01-2008, 09:27 PM   #8 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Indeed - it doesn't use a web server or web browser at all - runs just like a normal Windows or XWindows application

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-01-2008, 09:42 PM   #9 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

That's very impressive Alan, thanks for the tip once again. I am surely going to introduce it to my boss, maybe he can have his go with it.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-01-2008, 11:31 PM   #10 (permalink)
WebDev'n Beer Drnkn' Fool
 
stewart's Avatar
 
Join Date: Dec 2007
Location: Denver, CO
Posts: 59
Thanks: 2
stewart is on a distinguished road
Default

PHP-GTK is very interesting, it has come a long way now. I was looking forward to version 2 coming out for the longest time..

The betas have been available for quite some time now for v2.

Glad it is finally out xD!!!
__________________
stewart::howe
Web Developer & Programmer
CelerMedia.Com | iAmStewart.com | CelerLabs.com

Last edited by stewart : 03-02-2008 at 05:25 PM.
Send a message via ICQ to stewart Send a message via AIM to stewart Send a message via MSN to stewart Send a message via Yahoo to stewart
stewart is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:45 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design