|
hi i am new in php started some days ago to learn php and gtk. i tryed to make and example of a simple calculator, the example runs but when i click the buton of the op the app closes can you tell me what is the problem! thaks a lot from colombia!!! here is the code:
<?php
$w = new GtkWindow();
$w->set_title('GtkTable test');
$w->connect_simple('destroy', array('gtk', 'main_quit'));
$tem = new gtklabel('0');
$lbl1 = new GtkLabel('CAntidad A:');
$lbl2 = new GtkLabel('Cantidad B:');
$lbl3 = new GtkLabel('Resultado :');
$align3 = new GtkAlignment(0.0, 0.5, 0, 0);
$align3->add($lbl3);
$txt1 = new GtkEntry();
$txt2 = new GtkEntry();
$hbox= new gtkhbox();
$table = new GtkTable(3, 2);
$table->attach($lbl1 , 0, 1, 0, 1, Gtk::FILL);
$table->attach($lbl2 , 0, 1, 1, 2, Gtk::FILL);
$table->attach($align3, 0, 1, 2, 3, Gtk::FILL);
$table->attach($txt1 , 1, 2, 0, 1);
$table->attach($txt2 , 1, 2, 1, 2);
$table->attach($tem , 1, 2, 2, 3);
$table->attach($hbox , 0, 2, 3, 4);
$a=$txt1->get_text();
$b=$txt2->get_text();
$bot1= new GtkButton('sumar');
$bot2= new GtkButton('restar');
$bot3= new GtkButton('multiplicar');
$bot4= new GtkButton('dividir');
$hbox->pack_start($bot1);
$hbox->pack_start($bot2);
$hbox->pack_start($bot3);
$hbox->pack_start($bot4);
$bot1->connect_simple('clicked', 'sumar');
$bot2->connect_simple('clicked', 'restar');
$bot3->connect_simple('clicked', 'multiplicar');
$bot4->connect_simple('clicked', 'dividir');
function sumar()
{
$tem->set_text($a+$b);
}
function restar()
{
$tem->set_text($a-$b);
}
function multiplicar()
{
$tem->set_text($a*$b);
}
function dividir()
{
$tem->set_text($a/$b);
}
$w->add($table);
$w->show_all();
Gtk::main();
?>
|