« Return to Thread: Strange result

Re: Strange result

by Jake-57 :: Rate this Message:

Reply to Author | View in Thread

When I run your example I get two objects in the array, the output is:

This Key 0 IS an OBJECT
This Key 1 IS an OBJECT

Do I understand correctly that when you run it you get two
non-objects?  If so, you should provide information about your
environment; I don't see anything wrong with this code as is.

-Jake

On Wed, Oct 22, 2008 at 7:47 AM, AngeloP <leone@...> wrote:

>
> I want to make a main array named $objs=array()
>  that contains reference to the gtkentry that I' have in into a form
>
> for example I want to have somethig like this:
>
> $foo=array( object_a;object_b .... , last_obj );
>
> so I'm able with a comand like
>
> foreach($foo as $obj )
>
> to print  $obj->get_text(); or have other operations.
>
> Please see the code here under
>
> From the main program I istantite the class
> and then I append the entry object into array by the command
>
> array_push($objs, $test->get_objs0());
>
> but I must  make for two times an array push
>
> I would into class make a local  array push everi gtkentry obj into array
> and then when I get it  with command get_objs
> return the array with two object and push it
> to the main array
>
> with only one command array_push(....); !!!!!!
>
> I have tried to make an array into the class
> but it return no obj where I have made mistake ???
>
>
> Any has some Idea for solution ?
>
>
> Thanks
> -------------------------------------------------
> <?php
>
> class Rad_Entryb extends GtkHbox
> {
>
>  function __construct()
>        {
>          parent::__construct();
>        }
>
>
>      function spacer($container,$gap)
>      {
>        if($container -> get_name()== 'GtkHbox' )
>        {
>         //echo "horizontal spacer: $gap\n";
>         $spacer = new GtkHbox();
>         $spacer -> set_size_request($gap,0);
>         $container -> pack_start($spacer,$false);
>        }
>        else
>        {
>        //echo "vertical spacer: $gap\n";
>         $spacer = new GtkVbox();
>         $spacer -> set_size_request(0,$gap);
>         $container -> pack_start($spacer,$false);
>        }
>      }
>
>      function expandible_spacer($container)
>      {
>        $container->pack_start(new GtkHbox(),true);
>      }
>
> }
>
>
> class One_Label_Two_Field extends Rad_entryb
> {
>
>    private $objs0;
>    private $objs1;
>
>
>
>  function __construct($vbox,$label_uno,$entry_uno,$entry_due)
>        {
>
>         parent::__construct();
>
>
>
>    $this->spacer($this,3);
>
>    $lab= new GtkLabel();
>    $lab->set_text($label_uno);
>
>
>    $this->pack_start($lab,false);
>
>    $entry0= new GtkEntry();
>    $entry0->set_name($entry_uno);
>
>               $this->objs0= $entry0;
>
>    $this->pack_start($entry0,false);
>
>    $entry1= new GtkEntry();
>    $entry1->set_name($entry_due);
>
>                   $this->objs1= $entry1;
>
>
>    $this->pack_start($entry1,false);
>
>    $this->expandible_spacer($this);
>
>      $vbox -> pack_start($this,0);
>
>
>
>
>
>
> }
>
>
>
>
>        function get_objs0()
>        {
>          return $this->objs0;
>        }
>
>        function get_objs1()
>        {
>          return $this->objs1;
>        }
>
>
>
> }
>
>
> //Finestra semplice e un bottone
> $objs=array();
>
> // ===========================================================
> // Creazione finestra
> $window= new GtkWindow();
> $window->connect_simple('destroy',array('Gtk','main_quit'));
> $window->set_size_request(550,400); // imposta la dimensione della finestra
>
> // Creazionne delle righe
> $vbox= new GtkVBox();
> $window-> add($vbox);
>
>
> // PROBLEM PROBLEM
> $test = New One_Label_Two_Field($vbox,"Prodotto","prod_cod","prod_descr");
> array_push($objs, $test->get_objs0());
> array_push($objs, $test->get_objs1());
>
> foreach($objs as $key=>$obj)
> {
>  is_object( $obj  )?print "This Key ".$key." IS an OBJECT \n":print " This
> Key ".$key." IS NOT AN OBJECT \n";
> }
>
> $window->show_all();
> GTK::main();
>
>
> ?>
> --
> View this message in context: http://www.nabble.com/Strange-result-tp20109047p20109047.html
> Sent from the Php - GTK - General mailing list archive at Nabble.com.
>
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 « Return to Thread: Strange result