Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/07/2004, 11:35
Avatar de payo22
payo22
 
Fecha de Ingreso: noviembre-2002
Ubicación: México
Mensajes: 839
Antigüedad: 21 años, 6 meses
Puntos: 1
Código PHP:
        $this->gui['caja'] = &new GtkEntry();
         
$this->gui['caja']->set_editable(true);
                                                                                                                                                 
         
$this->gui['btn_consulta'] = &new GtkButton('Consultar');
         
$this->gui['btn_consulta']->connect('clicked',array($this,'busca_dato'),$this->gui['caja']);
                                                                                                                                                 
         
$this->gui['btn_salir'] = &new GtkButton('Salir');
         
$this->gui['btn_salir']->connect('clicked',array($this,'cerrar')); 
1.- se crea una caja en la cual capturaremos lo que queremos consultar

2.- se crea un boton 'btn_consulta' para que al ser presionado llame a la funcion busca_dato

3.- se crea un boton para salir del programa.

FUNCION busca_dato

Código PHP:
      function busca_dato($theButton){
         
$cadena $this->gui['caja']->get_text();
                                                                                                                                                 
         
$this->gui['ventana2']= &new GtkWindow();
         
$this->gui['ventana2']->set_title('Resultado de la consulta:');
         
$this->gui['ventana2']->set_usize(400,400);
         
$this->gui['ventana2']->set_position(GTK_WIN_POS_CENTER);
         
$this->gui['ventana2']->set_policy(false,false,false);
         
$this->gui['ventana2']->connect('destroy',array($this,'cerrar'));
                                                                                                                                                 
         
$this->gui['vbox_contenedor'] = &new GtkVBox(false,0);
         
$this->gui['hbox_padre'] = &new GtkHBox(false,0);
                                                                                                                                                 
         
$this->gui['hbox_lbl'] = &new GtkHBox(false,0);
         
$this->gui['hbox_entry'] = &new GtkHBox(false,0);
                                                                                                                                                 
         
$this->gui['vbox_lbl'] = &new GtkVBox(false,0);
         
$this->gui['vbox_entry'] = &new GtkVBox(false,0);
                                                                                                                                                 
         
$this->gui['lbl_pais'] = &new GtkLabel("Pais");
         
$this->gui['lbl_capital'] = &new GtkLabel("Capital");
         
$this->gui['lbl_cont'] = &new GtkLabel("Continente");
                                                                                                                                                 
         
$this->gui['txt_pais']=&new GtkEntry();
         
$this->gui['txt_cap']=&new GtkEntry();
         
$this->gui['txt_cont']=&new GtkEntry();
                                                                                                                                                 
         
$this->gui['box'] = &new GtkHButtonBox();
         
$this->gui['box']->set_border_width(5);
         
$this->gui['box']->set_layout(GTK_BUTTONBOX_SPREAD);
         
$this->gui['box']->set_spacing(5);
         
$this->gui['box']->set_child_size(15,20);
                                                                                                                                                 
         
$link mysql_connect("localhost","root","admin");
         
mysql_select_db("Tierra",$link);
         
$sql "Select * from pais where Nombre = '$cadena'";
         
$result mysql_query($sql,$link);
                                                                                                                                                 
        if (
$row mysql_fetch_array($result)){
           do{
               
$id $row[id];
               
$this->gui['txt_pais']->set_text($row['Nombre']);
               
$this->gui['txt_cap']->set_text($row['Capital']);
               
$this->gui['txt_cont']->set_text($row['Continente']);
           }while(
$row mysql_fetch_array($result));
                                                                                                                                                 
         
$this->gui['btn_salir'] = &new GtkButton('Salir');
         
$this->gui['btn_salir']->connect('clicked',array($this,'cerrar'));
                                                                                                                                                 
         
$this->gui['vbox_lbl']->pack_start($this->gui['lbl_pais']);
         
$this->gui['vbox_lbl']->pack_start($this->gui['lbl_capital']);
         
$this->gui['vbox_lbl']->pack_start($this->gui['lbl_cont']);
                                                                                                                                                 
         
$this->gui['vbox_entry']->pack_start($this->gui['txt_pais']);
         
$this->gui['vbox_entry']->pack_start($this->gui['txt_cap']);
         
$this->gui['vbox_entry']->pack_start($this->gui['txt_cont']);
                                                                                                                                                 
         
$this->gui['hbox_lbl']->pack_start($this->gui['vbox_lbl']);
         
$this->gui['hbox_entry']->pack_start($this->gui['vbox_entry']);
         
$this->gui['hbox_padre']->pack_start($this->gui['hbox_lbl']);
         
$this->gui['hbox_padre']->pack_start($this->gui['hbox_entry']);
                                                                                                                                                 
         
$this->gui['box']->pack_start($this->gui['btn_salir'],false);
         
$this->gui['box']->show();
                                                                                                                                                 
         
$this->gui['vbox_contenedor']->pack_start($this->gui['hbox_padre']);
         
$this->gui['vbox_contenedor']->pack_start($this->gui['box']);
         
$this->gui['ventana2']->add($this->gui['vbox_contenedor']);
                                                                                                                                                 
         
$this->gui['ventana2']->show_all();
        }else{
             echo 
"No se encontro ningun registro !!! \n";
        }
//fin if
      
}//termina funcion busca dato