GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help a rookie!

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
francisco



Joined: 12 Mar 2007
Posts: 1
Location: Colombia

PostPosted: Fri Mar 16, 2007 12:03 pm    Post subject: Help a rookie! Reply with quote

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();
?>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP