VB icon

PHP GTK Entry Form

Email
Submitted on: 1/1/2015 10:04:00 AM
By: Mandar Kelkar (from psc cd)  
Level: Advanced
User Rating: By 9 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 1999
 
     Initial code for PHPGTK using GtkLabel, GtkText, GtkRadiobutton,GtkButton,GtkEntry.

 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :PHP GTK Entry Form
//**************************************
No Copyright
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: PHP GTK Entry Form
// Description:Initial code for PHPGTK using GtkLabel, GtkText, GtkRadiobutton,GtkButton,GtkEntry.
// By: Mandar Kelkar (from psc cd)
//
// Inputs:Input form using GtkLabel, GtkText,GtkRadiobutton,GtkButton,GtkEntry
Basic Entry => Name , Address , Phone , Sex
//
// Returns:Captures the data entered on prompt.
Will upgrade soon so it enters into database and displayed on GtkWindow widget.
//
// Assumes:No Assumptions ..
//
// Side Effects:No side effects :-)
You will learn more PhpGtk
//**************************************

<?php
/* 
Simple Entry Form Using PHP GTK
Author Mandar Kelkar
Email kelkar_mandar@yahoo.com
*/
if (!class_exists('gtk')){
	strtoupper(substr(PHP_OS,0,3) == 'WIN')?dl('php_gtk.dll'):dl('php_gtk.so');
	}
//Get the initial window with specific settings
$window = &new GtkWindow();
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_title("Entry Form");
$window->set_border_width(5);
//$window->set_default_size((gdk::screen_width()/4),(gdk::screen_height()-80));
$window->set_default_size(500,300);
$window->connect_object("destroy", array("gtk","main_quit"));
$window->set_policy(false, false, false);
$window->realize();
 
//Get GTK TABLE and add it to the window
$table = &new GtkTable(4,2);
$table->set_row_spacings(5);
$table->set_col_spacings(5);
$window->add($table);
$name = &new GtkLabel("Your Name");
/*$tp = $name->get_colormap();
$tp->alloc(235,2,2);
$name->set_colormap($tp);
$name->set_usize(20,100);*/
$name->set_justify(GTK_JUSTIFY_FILL);
$table->attach($name,0,1,0,1);
$nametext = &new GtkEntry();
$nametext->set_editable(true);
//$nametext->set_usize(20,100);
$table->attach($nametext,2,3,0,1);
$address = &new GtkLabel("Your Address");
$address->set_justify(GTK_JUSTIFY_FILL);
//$address->set_usize(20,100);
$table->attach($address,0,1,1,2);
$addresstext = &new GtkText();
$addresstext->set_editable(true);
//$addresstext->set_usize(20,100);
$table->attach($addresstext,2,3,1,2); 
$phone = &new GtkLabel("Phone No");
$phone->set_justify(GTK_JUSTIFY_FILL);
$table->attach($phone,0,1,2,3);
$phoneno = &new GtkEntry();
$phoneno->set_editable(true);
$table->attach($phoneno,2,3,2,3);
$sexlabel = &new GtkLabel("Sex");
$sexlabel->set_justify(GTK_JUSTIFY_FILL);
$table->attach($sexlabel,0,1,3,4);
$male = &new GtkRadioButton(null,'Male');
$female = &new GtkRadioButton($male,"Female");
$male->set_active(true);
$male->connect('pressed','sexfunc','male');
$female->connect('pressed','sexfunc','female');
$table->attach($male,2,3,3,4);
$table->attach($female,2,3,4,5);
$submit = &new GtkButton("Submit");
$submit->connect('clicked','Showdetails');
$table->attach($submit,2,3,6,7);
function sexfunc($widget,$sexvar){
global $varsex;
$varsex = $sexvar;
}
function Showdetails(){
global $window,$addresstext,$phoneno,$nametext,$varsex;
$enteredname = $nametext->get_text();
$enteredphone = $phoneno->get_text();
$len = $addresstext->get_length();
$newaddresstext = $addresstext->get_chars(0,$len);
print "\n Hi are the details from form => \n 
		 Name = $enteredname \n
		 address = $newaddresstext \n
		 phone = $enteredphone \n
		 sex = $varsex\n \n";
Gtk::main_quit();
}
$window->show_all();
gtk::main();
?>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.