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.
Пример 82. 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();
?>
|
Виж също: get_label() , set_text() , set_markup()