PHP-GTK
Thursday, October 23, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkLabel::set_justify
GtkLabel::set_line_wrapnext

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

GtkLabel::set_label

Sets the text of the label. The label is interpreted as including embedded underlines and/or Pango markup depending on the values of set_use_underline() and set_use_markup()

By default, use_markup is not activated - you've got to enable it before markup will be interpreted.

Example 85. Setting the Text of a GtkLabel with Pango Markup

<?php
function updateCounter($label)
{
    // Set the label to the current label plus one in a random color.
    $randColor = substr(dechex(rand()), 0, 6);
    $label->set_label('<span color="#' . $randColor . '">' . 
                      ($label->get_text() + 1) .
                      '</span>'
                      );
}
 
// Create a window to hold the label.
$window = new GtkWindow();
 
// Set up the window to close cleanly.
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
 
// Create a label.
$label = new GtkLabel('0');
 
// Set the label to use markup.
$label->set_use_markup(true);
 
// Create a button that will be used to increment the counter.
$button = new GtkButton('Click Me!');
 
// When the button is clicked, the counter should be updated.
$button->connect_simple('clicked', 'updateCounter', $label);
 
// Create a vbox to hold the label and button.
$vBox = new GtkVBox();
 
// Add the label & button to the box.
$vBox->pack_start($label);
$vBox->pack_start($button);
 
// Add the box to the window.
$window->add($vBox);
 
// Show the window and start the main loop.
$window->show_all();
Gtk::main();
?>

See also: get_label() , set_text() , set_markup()


User Contributed Notes
gtk.gtklabel.method.set_label.php
add a note about notes
There are no user contributed notes for this page.


previousGtkLabel::set_justify
GtkLabel::set_line_wrapnext

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:59 2013 CEST