PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:GtkEntry() and get_text(); (2 viewing) (2) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: Re:GtkEntry() and get_text();


#2837
veron (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
GtkEntry() and get_text(); 10 Months, 2 Weeks ago Karma: 0  
I am using several files with class extends GtkWindow, so the problem is the following,I try to get the data from GTKEntry() by means of get_text, but unfortunately I got nothing, I don't know if the problem is with parent ::, Please check the below to tell me what's wrong.

// having previously
$input = $name12->get_text();
$input2 = $name22->get_text();
$input3 = $name33->get_text();
$input4 = $name44->get_text();
// the problem is here
if ($input ==''($input2=='') || ($input3=='') || ($input4==''){
$buttonx->connect_simple ( 'clicked' , array( $this , 'click2' ));
}

Code:
<?php
/*
*
*/
class Otraventana extends GtkWindow
{
/*
*
*/
private $mimensaje ;
private $mimensaje2 ;
private $mimensaje3 ;



function __construct ()
{
parent :: __construct ();
//parent :: GtkEntry();
//parent :: get_text();
parent :: set_size_request ( 450 , 250 );
parent :: set_border_width ( 50 );
parent :: set_title ( 'otra ventana 4' );
parent :: connect_simple ( 'connect' , array( $this , 'on_click' ));
parent :: connect_simple ( 'delete_event' , array( $this , 'clicou' ));

$vbox = new GtkVBox ;
global $name12, $name22, $name33, $name44, $input, $input2, $input3, $input4;

$title = new GtkLabel("Usted va a crear un nuevo grupo \npara matricular un grupo de estudiante");
$title->modify_font(new PangoFontDescription("Times New Roman Italic 10"));
$title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff"));
$title->set_size_request(-1, 40);
$title->set_justify(Gtk::JUSTIFY_CENTER);
$alignment = new GtkAlignment(0.5, 0, 0, 0);
$alignment->add($title);
$vbox->pack_start($alignment, 0, 0);
$vbox->pack_start(new GtkLabel(), 0, 0);

// setup the entry field
$hbox = new GtkHBox();

$vbox->pack_start($hbox, 0, 0);

$hbox->pack_start(new GtkLabel("                       Nivel:"), 0, 0);
$name12 = new GtkEntry();
$name12->set_size_request(40, 20);
$hbox->pack_start($name12, 0, 0);

$hbox->pack_start(new GtkLabel("    Dia(2 letras):"), 0, 0);
$name22 = new GtkEntry();
$name22->set_size_request(40, 20);
$hbox->pack_start($name22, 0, 0);

$hbox->pack_start(new GtkLabel("    Turno:"), 0, 0);
$name33 = new GtkEntry();
$name33->set_size_request(40, 20);
$hbox->pack_start($name33, 0, 0);

$hbox->pack_start(new GtkLabel("    Aņo:"), 0, 0);
$name44 = new GtkEntry();
$name44->set_size_request(40, 20);
$hbox->pack_start($name44, 0, 0);

$buttonx = new GtkButton('Crear Ya');
$buttonx->set_size_request(80, 28);

/******* para mandar mensajes *********************/ 
echo "on_click: $id!\n";

        $input = $name12->get_text();
        $input2 = $name22->get_text();
	$input3 = $name33->get_text();
        $input4 = $name44->get_text();

// the problem is here 
if ($input ==''($input2=='') || ($input3=='') || ($input4==''){
	$buttonx->connect_simple ( 'clicked' , array( $this , 'click2' ));
}

else{
$fecha=date("y-m-d");
		include 'conex01.php'; 
		$SQL="SELECT nombre FROM grupos WHERE nombre = '$input'.'$input2'.'$input3'.'$input4'"; 	
		//$SQL = "SELECT idma, nombre, nivel FROM materias";
		$result = mysql_query($SQL) or die('Query failed. ' . mysql_error());  
       		if (mysql_num_rows($result) >= 1) {
			$buttonx->connect_simple ( 'clicked' , array( $this , 'click3' ));
		}
		else{
		$conv=$input."".$input2."".$input3."".$input;
		$SQL = "INSERT INTO grupos (nombre, system) VALUES ('$conv', '$fecha')";
		mysql_query($SQL) or die('Error ,query failed');

		$buttonx->connect_simple ( 'clicked' , array( $this , 'click4' ));
	
		//mysql_close($conn);
		}
		mysql_close($conn);		
}

/********* fin de para mandar mensajes ***********/
//$buttonx->connect_simple ( 'clicked' , array( $this , 'click2' )); //connect('clicked', 'on_click', 'AA');

$hbox = new GtkHBox();
$vbox->pack_start($hbox, 0, 0);
$hbox->pack_start(new GtkLabel());
$hbox->pack_start($buttonx, 0, 0);

global $message;

$hbox->pack_start(new GtkLabel($message));

$vbox->pack_start(new GtkLabel("Hola es el boton 4 que abre esta ventana"));
$vbox->pack_start(new GtkLabel());

$vbox->pack_start($hbox=new GtkHBox(), 0, 0);

$hbox->pack_start($botao = new GtkButton ( 'fecha otro 4' ));
$botao->set_size_request(40, 32);
$botao -> connect_simple ( 'clicked' , array( $this , 'clicou' ));

parent :: add ( $vbox );
parent :: add ( $hbox );

parent :: show_all ();

}

/*********************/


/********************/
/*
*
*/
function click2 ()
{
include_once 'mesage.php' ;
	

          if (empty( $this -> mimensaje ))
	   {
		$this -> mimensaje = new message ;
	   }
	   $this -> mimensaje -> show_all ();
 }
function click3 ()
{

include_once 'mesage2.php' ;


          if (empty( $this -> mimensaje2 ))
	   {
		$this -> mimensaje2 = new message2 ;
	   }
	   $this -> mimensaje2 -> show_all ();
}
function click4 ()
{

include_once 'mesage3.php' ;

           if (empty( $this -> mimensaje3 ))
	   {
		$this -> mimensaje3 = new message3 ;
	   }
	   $this -> mimensaje3 -> show_all ();
        
}

function clicou ()
{
$this -> hide ();
return true ;
}
}
?> 
 
 
Last Edit: 2009/10/24 11:07 By veron.
  The administrator has disabled public write access.

#2840
kksou (Admin)
Admin
Posts: 1240
graph
User Online Now Click here to see the profile of this user
Re:GtkEntry() and get_text(); 10 Months, 2 Weeks ago Karma: 20  
Hi,

You set up the GtkEntry then immediately get their values using GtkEntry::get_text(). Of course you'll always get null value for all the GtkEntry's.

You have to set up the GtkEntry first then let the user enter the values before you retrieve the values.

You may want to refer to any of the sample codes on GtkEntry to see how we usually use the GtkEntry:

List Sample Codes by Widgets - GtkEntry

Regards,
/kksou
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved