PHP-GTK
Tuesday, September 23, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkEntry
GtkEntry::append_textnext

Last updated: Sun, 12 May 2013
view this page in English

GtkEntry Constructor

GtkEntry ([ string text [, int max ]]);

Creates a widget that will hold a single line of text. You have the freedom to either set the widget programatically through set_text() or have it entered by the user.

If text is given, it will be set as the default value for the widget. If max is given, it will be set as the maximum allowed length of the widget's text value in characters.

Example 59. Retrieving text and echoing it using GtkEntry

<?php
//Function to retrieve text from GtkEntry and print it
function get_input($entry) {
    $input = $entry->get_text();
    echo "$input\r\n";
    $entry->grab_focus();
    $entry->set_text("");
}
 
//Setting up the Window
// Note the usage of connect_simple()
// instead of deprecated connect_object()
$window = new GtkWindow();
$window->set_position(Gtk::WIN_POS_CENTER);
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
 
//Adding a box to the Window to allow more than one Child
$box = new GtkVBox();
$window->add($box);
 
//Adding the GtkEntry widget and connecting
// it to the callback function: get_text()
$entry = new GtkEntry();
$entry->connect('activate', 'get_input');
$box->add($entry);
 
//Adding a GtkButton to the box and use connect_simple()
// so that it will pass the GtkEntry to the callback
// function when it is clicked
$button = new GtkButton('Click Me to echo input!');
$button->connect_simple('clicked', 'get_input', $entry);
$box->add($button);
 
//Display everything and start the main loop
$window->show_all();
Gtk::main();
?>

User Contributed Notes
gtk.gtkentry.constructor.php
add a note about notes
There are no user contributed notes for this page.


previousGtkEntry
GtkEntry::append_textnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:50:57 2013 CEST