Re: object oriented approach
| From: | (PHPDiscuss - PHP Newsgroups and mailing lists) | Date: | Sun, 04 Jul 2004 21:24:19 +0000 |
| Subject: | Re: object oriented approach | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-4701@lists.php.net to get a copy of this message | ||
Well I had the same problem and I have solved it like this
you have to always use the connect_object('clicked' ,array(&$this ,
'your_function'));
Here is a little working example
<?php
class TelGui
{
var $window;
var $oudestand;
var $nieuwstand;
var $vbox;
function kopier()
{
echo 'It works';
}
function TelGui() {
$this->window = &new GtkWindow();
$this->window->set_title('Mijn teller proggietje');
$this->window->connect_object('destroy', array('Gtk',
'Main_quit'));
$this->window->set_usize(gdk::screen_width()-80,gdk::screen_height()-80);
$this->window->set_border_width(10);
$this->window->set_position(GTK_WIN_POS_CENTER);
$this->vbox = &new GtkVBox();
$this->window->add($this->vbox);
$this->oudestand = &new GtkEntry();
$this->nieuwstand = &new GtkEntry();
$this->knop = &new GtkButton("Vul In");
$this->knop->connect_object('clicked', array(&$this,'kopier'));
$this->vbox->pack_start(new GtkLabel("Een leuke test"));
$this->vbox->pack_start($this->oudestand);
$this->vbox->pack_start($this->nieuwstand);
$this->vbox->pack_start($this->knop);
$this->window->realize();
$this->window->show_all();
}
};
new TelGUI;
Gtk::main();
?>
Greetz
Wim Stockman from Belgium
Szilard Novaki wrote:
> Hi!
> I'm a newbie at php-gtk. It's very impressive, but i'd like to use it in
> object oriented way.
> I've read a hello-world application. It very simple, but I could not
> convert it to an object oriented structure, because the event callback
> (as far as I see) is a php function. Could anyone send me an object
> oriented php-gtk application, where the gtk widgets are objects? A hello
> world application would be just fine.
> Thank you,
> Szilard