GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Apr 18, 2014 6:15 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Help a rookie!
PostPosted: Fri Mar 16, 2007 12:03 pm 
Offline

Joined: Mon Mar 12, 2007 3:04 pm
Posts: 1
Location: Colombia
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();
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group