| Scripts interactivos en modo gráfico: KDE y PHP | ||
|---|---|---|
| Anterior | ||
Y ahora algunos ejemplos simples de uso de la clase kdialog.
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$a=$kd->leer_clave($MSGINTRO,"Dime tu sueldo:");
if ($kd->error == 0 )
$kd->aviso($MSGAVISO, " No me lo creo, $a euros:");
else
$kd->aviso($MSGAVISO, " Ha pulsado: Cancel");
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$a=$kd->leer_clave($MSGINTRO,"Por favor introduzca la contraseña:");
if ($kd->error == 0 )
$kd->aviso($MSGAVISO, " Pues es $a");
else
$kd->aviso($MSGAVISO, " Ha pulsado: Cancel");
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$dir=$kd->leer_dir("Directorio");
if ($kd->error==0)
$kd->aviso($MSGAVISO, " El directorio es : $dir");
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$filtro="*.txt | ficheros de texto";
$fich=$kd->leer_fichero("Fichero",$filtro);
if ($kd->error==0)
$kd->aviso($MSGAVISO, " El fichero es : $fich");
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$fichero=$kd->leer_fichero("Fichero");
if ($kd->error==0)
{
$kd->mostrar_fichero($fichero, $fichero,400, 200);
}
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$a=array("1"=>"uno","2"=>"dos","3"=>"tres");
$opciones=serialize($a);
$f=$kd->mostrar_menu("Selecci�","Seleccione una sola opcion",$opciones);
$kd->aviso($MSGAVISO, " Su selecci� es: $f");
$a=$kd->mostrar_check("Selecci�","Puede seleccionar varias opciones",$opciones,"1");
$a=explode(" ",$a);
for($i=0;$i<count($a);$i++)
$kd->aviso($MSGAVISO, " Su selecci� es: $a[$i]");
$a=$kd->leer_sino("Mostrar","Quiere abrir un select?");
if ($kd->error()==0)
{
$a=$kd->mostrar_select("Selección","Puede seleccionar varias opciones",$opciones);
$kd->aviso($MSGAVISO, " Su selección es: $a");
}
?>
|
#!/usr/bin/php
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$db=mysql_connect("localhost","root","");
$res=mysql_list_dbs($db);
while(list($dbd[])=mysql_fetch_row($res));
$lista=serialize($dbd);
$a=$kd->mostrar_select("Selecció","Seleccione la base de datos",$lista);
if ($kd->error()==0)
{
mysql_select_db($a);
$res=mysql_list_tables($a,$db);
while(list($dbt[])=mysql_fetch_row($res));
$lista=serialize($dbt);
$a=$kd->mostrar_select("Selección","Seleccione la tabla ",$lista);
}
?>
|
<?php
#include "kdialog.php";
$kd=new kdialog;
$MSGINTRO="Introducir datos";
$MSGAVISO="Atención";
$a=$kd->leer_clave($MSGINTRO,"Por favor introduzca la contraseña:");
if ($kd->error == 0 )
$kd->aviso($MSGAVISO, " Ha pulsado: OK");
else
$kd->aviso($MSGAVISO, " Ha pulsado: Cancel");
$b=$kd->leer($MSGINTRO,"Por favor introduzca su nombre:");
if ($kd->error==0 )
$kd->aviso($MSGAVISO, " Ha pulsado: OK");
else
$kd->aviso($MSGAVISO, " Ha pulsado: Cancel");
$kd->aviso($MSGAVISO, " Ha escrito: $a");
$kd->aviso($MSGAVISO, " Su nombre es: $b");
$dir=$kd->leer_dir("Directorio");
if ($kd->error==0)
$kd->aviso($MSGAVISO, " El directorio es : $dir");
$fichero=$kd->leer_fichero("Fichero");
if ($kd->error==0)
{
$kd->mostrar_fichero($fichero, $fichero,400, 200);
}
$a=array("1"=>"uno","2"=>"dos","3"=>"tres");
$opciones=serialize($a);
$f=$kd->mostrar_menu("Selecci�","Seleccione una sola opcion",$opciones);
$kd->aviso($MSGAVISO, " Su selecci� es: $f");
$a=$kd->mostrar_check("Selecci�","Puede seleccionar varias opciones",$opciones,"1");
$a=explode(" ",$a);
for($i=0;$i<count($a);$i++)
$kd->aviso($MSGAVISO, " Su selecci� es: $a[$i]");
$a=$kd->leer_sino("Mostrar","Quiere abrir un select?");
if ($kd->error()==0)
{
$a=$kd->mostrar_select("Selección","Puede seleccionar varias opciones",$opciones);
$kd->aviso($MSGAVISO, " Su selección es: $a");
}
$db=mysql_connect("localhost","root","");
$res=mysql_list_dbs($db);
while(list($dbd[])=mysql_fetch_row($res));
$lista=serialize($dbd);
$a=$kd->mostrar_select("Selecció","Seleccione la base de datos",$lista);
if ($kd->error()==0)
{
mysql_select_db($a);
$res=mysql_list_tables($a,$db);
while(list($dbt[])=mysql_fetch_row($res));
$lista=serialize($dbt);
$a=$kd->mostrar_select("Selección","Seleccione la tabla ",$lista);
}
?>
|