Re: Problem extending GtkVBox
| From: | Simon Wheeler | Date: | Fri, 09 Jan 2004 16:49:25 +0000 |
| Subject: | Re: Problem extending GtkVBox | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-4351@lists.php.net to get a copy of this message | ||
Hi , for now (eg php4) you (AFAIK) >have to< do this...
class LabeledEntry extends GtkVBox {
var $arrChildren;
function LabeledEntry($labelText,$entryText) {
parent::GtkVBox(false,0);
$this->arrChildren = array();
$label = &new GtkLabel($labelText);
$label->set_alignment(0,0);
$entry = &new GtkEntry();
$entry->set_text($entryText);
$this->arrChildren['label'] = $label ;
$this->arrChildren['entry'] = $entry ;
$this->pack_start($this->arrChildren['label']);
$this->pack_start($this->arrChildren['entry']);
}
//and dereference elsewhere as well , e.g.
function getEntryText($text) {
$entry = $this->arrChildren['entry'] ;
return $entry->get_text();
}
I think this is supposed to be getting better with php5.
Regards,
Simon.
----- Original Message -----
From: "Douglas Douglas" <replaceafill@yahoo.com>
Newsgroups: php.gtk.general
To: <php-gtk-general@lists.php.net>
Sent: Thursday, January 08, 2004 2:54 PM
Subject: Problem extending GtkVBox
> Hello.
>
> I need to build an object having a label and an entry
> in it (I'm making it an object because I'm going to
> need six of them). I'm extending the GtkVBox, like
> this:
>
> class LabeledEntry extends GtkVBox {
> var $arrChildren;
> function LabeledEntry($labelText,$entryText) {
> parent::GtkBox(false,0);
> $this->arrChildren = array();
> $this->arrChildren['label'] = &new
> GtkLabel($labelText);
>
> $this->arrChildren['label']->set_alignment(0,0);
>
> $this->pack_start($this->arrChildren['label']);
> $this->arrChildren['entry'] = &new
> GtkEntry();
>
> $this->arrChildren['entry']->set_text($entryText);
>
> $this->pack_start($this->arrChildren['entry']);
> }
>
> function getEntryText($text) {
> return
> $this->arrChildren['entry']->get_text();
> }
>
> function setEntryText($text) {
>
> $this->arrChildren['entry']->set_text($text);
> }
> }
>
> But it gives me this error:
>
> Fatal error: Cannot create references to/from string
> offsets nor overloaded objects in
> C:\php4\Rectangle.php on line 9
>
> What could be the problem? Thanks for any help.
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus