estoy intentando aprender php-gtk y me esta costando lo suyo hacer algunas cosas muy simples.
Por ejemplo, estoy haciendo un formulario y he querido meterle unos radio buttons, lo he hecho pero ahora no se como ver cual es el seleccionado.
esto es todo lo que he conseguido hacer hasta ahora, no pretendo hacer nada en particular, solo mostrar el sexo seleccionado cuando pincha en enviar e ir pillandole el truco a esto...
Código PHP:
<?php
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")) ||
die("Can't load php_gtk module!\n");
function fEscribir()
{ global $lblTexto,$txtNombre,$txtEdad,$txtRadio;
$intEdad=$txtEdad->get_text();
if ($intEdad=="" || is_nan($intEdad))
{ //return true;
}
$intAnho=date("Y")-$intEdad;
//$lblTexto->set_text("Te llamas ".$txtNombre->get_text()." y tienes ".$intEdad." años, así que eres del ". $intAnho);
$lblTexto->set_text("hola".$txtRadio);
return true;
}
function fSeleccionar($istrTexto)
{ global $txtRadio;
$txtRadio=$istrTexto;
}
$window = &new GtkWindow();
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_default_size(gdk::screen_width()/2, gdk::screen_height()/2);
$window->connect_object("destroy", array("gtk", "main_quit"));
$fixed = &new GtkFixed;
$lblNombre = &new GtkLabel("Nombre");
$fixed->put($lblNombre, 40,40);
$txtNombre = &new GtkEntry();
$fixed->put($txtNombre, 140,40);
$lblEdad = &new GtkLabel("Edad");
$fixed->put($lblEdad, 40,80);
$txtEdad = &new GtkEntry();
$fixed->put($txtEdad, 140,80);
$lblSexo = &new GtkLabel("Sexo");
$fixed->put($lblSexo, 40,120);
$vbox = &new GtkVbox();
$rdb1 = &new GtkRadioButton(null, "Masculino");
$rdb1->show();
$rdb1->connect('pressed','fSeleccionar','Masculino');
$vbox->pack_start($rdb1);
$rdb2 = &new GtkRadioButton($rdb1, "Femenino");
$rdb2->show();
$rdb2->connect('pressed','fSeleccionar','Femenino');
$vbox->pack_start($rdb2);
$vbox->show();
$fixed->put($vbox, 140,120);
$lblTexto=&new GtkLabel("");
$fixed->put($lblTexto, 40,160);
$button = &new GtkButton("Enviar");
$button->connect('clicked', 'fEscribir');
$fixed->put($button, 40,200);
$window->add($fixed);
$window->show_all();
gtk::main();
?>