Foros del Web » Programando para Internet » PHP » PHP-GTK »

muy basico...radio buttons

Estas en el tema de muy basico...radio buttons en el foro de PHP-GTK en Foros del Web. Buenas! 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 ...
  #1 (permalink)  
Antiguo 15/07/2005, 05:33
 
Fecha de Ingreso: diciembre-2002
Mensajes: 27
Antigüedad: 22 años, 7 meses
Puntos: 0
muy basico...radio buttons

Buenas!

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()/2gdk::screen_height()/2);
$window->connect_object("destroy", array("gtk""main_quit"));

$fixed = &new GtkFixed;
$lblNombre = &new GtkLabel("Nombre");
$fixed->put($lblNombre40,40);
$txtNombre = &new GtkEntry();
$fixed->put($txtNombre140,40);
$lblEdad = &new GtkLabel("Edad");
$fixed->put($lblEdad40,80);
$txtEdad = &new GtkEntry();
$fixed->put($txtEdad140,80);
$lblSexo = &new GtkLabel("Sexo");
$fixed->put($lblSexo40,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($vbox140,120);
$lblTexto=&new GtkLabel("");
$fixed->put($lblTexto40,160);
$button = &new GtkButton("Enviar");
$button->connect('clicked''fEscribir');
$fixed->put($button40,200);
$window->add($fixed);



$window->show_all();
gtk::main();

?>
  #2 (permalink)  
Antiguo 18/07/2005, 00:08
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 23 años, 9 meses
Puntos: 5
hay que visitar http://gtk.php.net

hay que visitar mas el manual oficial antes de preguntar y leerse los comentarios de los usuarios.

Aqui te dejo un ejemplo:

Código PHP:
<?php

dl
('php_gtk.' . (strstr(PHP_OS'WIN') ? 'dll' 'so'));

function 
here_goes($button) {
  
$child $button->child;
  echo 
$child->get()."\n";
}

$window = &new GtkWindow();
$window->connect_object('destroy', array('gtk''main_quit'));
$window->set_title('GtkRadioButton demo');

$box = &new GtkVBox();
$window->add($box);

$button1 = &new GtkRadioButton(null'button 1');
$button1->connect('pressed''here_goes');
$box->pack_start($button1);

for (
$i 2$i <= 4$i++) {
  
$button = &new GtkRadioButton($button1'button ' $i);
  
$button->connect('pressed''here_goes');
  
$box->pack_start($button);
}

$button_end = &new GtkButton('Exit');
$button_end->connect_object('clicked', array('gtk''main_quit'));
$box->pack_end($button_end);

$window->show_all();

gtk::main();

?>
Si lo que quieres es almacenar algun tipo de informacion utiliza el metodo _set_data() y get_data() del widget para almacenar la información que desees
__________________
Usuario registrado de Linux #288725
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:44.