[php-objects] php-gtk with classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hallo,

my problem is the following class that use a method of its own 
named "Fenster::change()" A simple operation for testing
When I create a "Fenster" instance by clicking the button in the main 
window into the gtk::main loop the instance of Fenster occures but 
the Fenster::change method doesnt work
When I create the instance of Fenster like 
 $MyFenster = &new Fenster(); into the main loop (see end of script)
the Fenster::change() method works fine !


I would so happy if someone can give me a hint what's going wrong in 
this example below:

<?php
....

class Fenster {
 var $window;
 var $field;
 var $button;
 

 function Fenster() {
  $this->window = new GtkWindow();
  $this->field = new GtkEntry();
  $this->button = new GtkButton("OK");
  
  $this->window->set_usize(300,200);
  $this->field->set_text("Hallo World");
  
  //only formating
  $vbox = &new GtkVBox();
  $vbox_button = &new GtkHBox();
  $vbox_button->set_border_width(60);
  $vbox->set_border_width(15);
  $hbox  = &new GtkHBox();
  $hbox->pack_start($this->field);
  $vbox_button->pack_end($this->button);
  $vbox->pack_start($hbox);
  $vbox->pack_start($vbox_button);
  $this->window->add($vbox);
  //call back for the clicked signal, just a method of Fenster class
  $this->button->connect_object("clicked", array(&$this,"change"));
  $this->window->show_all();
 }
 
 function change() {
 $this->field->set_text("hallo again...");
 
 }
}

//main window
//main window with a button to create an instance of Fenster 
//this way is makes problems
$window_main = &new GtkWindow();
$window_main->connect_object("destroy", array("gtk", "main_quit") );
$window_main->set_usize(300, 300);
$window_main->set_position(GTK_WIN_POS_CENTER);
 
$table = &new GtkTable(2, 2, false);
$window_main->add($table);
 
$button1 = &new GtkButton(' New Window ');
//call constructor of Fenster
$button1->connect_object('clicked', array('Fenster', 'Fenster'));
$table->attach($button1, 0, 1, 0, 1, 0, 0, 10, 10);
 
$window_main->show_all();

//alternatve ..
//$MyFenster = &new Fenster();  //this way is ok
gtk::main();

?>

Why does this script works only in one way ???
Thanks 10000000  times
 
Daniel





Look here for Free PHP Classes of objects:
http://phpclasses.UpperDesign.com/
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@egroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux