Re: change tooltip on the fly
| From: | Steph Fox | Date: | Mon, 09 Jan 2006 04:21:11 +0000 |
| Subject: | Re: change tooltip on the fly | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6513@lists.php.net to get a copy of this message | ||
cute :)
----- Original Message ----- From: "Ron Tarrant" <rtarrant@sympatico.ca>
To: <php-gtk-general@lists.php.net>
Sent: Monday, January 09, 2006 5:29 AM
Subject: Re: [PHP-GTK] change tooltip on the fly
Anyone have a recommendation for changing a tooltip message on the fly?
My attempt to do this results in a wonky tooltip that will rarely display and
when it does it goes away almost immediately... I'm trying to change the text
once a second in a function registered in the add timeout way. then I use:
$tooltips->set_tip( $eventbox, $msg, NULL);
$tooltips and $eventbox are global within the function.
Thanks for any pointers.
Here's a bit of code I came up with using buttons to change the tooltip on "My Label." In theory, you should be able to adapt it to change on a timer.
Hopefully everything is self-explanatory, but if not, let me know.
-Ron T.
PS: This works with PHP-Gtk2, but I don't know if it'll work with version one.
-----------------------------code starts here-------------------
<?php
/*
* Make Sure we have the libraries loaded.
*/
if(!class_exists('gtk'))
{
die('Please load the php-gtk2 module in your php.ini' . "\r\n");
}
define("MOUSE_EVENTS", Gdk::BUTTON1_MOTION_MASK
| Gdk::BUTTON_PRESS_MASK
| Gdk::BUTTON1_MASK
| Gdk::BUTTON2_MASK
| Gdk::BUTTON3_MASK
| Gdk::BUTTON_RELEASE_MASK
| Gdk::POINTER_MOTION_HINT_MASK);
// change the label text
function changeLabelText($label, $newText, $tooltips, $button)
{
$label->set_text($newText);
$tooltips->set_tip($button, $label->get_text());
} // changeLabelText()
$window = new GtkWindow();
$window->connect_simple('destroy', array('gtk', 'main_quit'));
$button1 = new GtkButton();
$button2 = new GtkButton();
$button3 = new GtkButton();
$label = new GtkLabel();
$label->set_angle(90);
$label->set_text("My Label");
$label->set_size_request(28, 100);
$hbox = new GtkHBox();
$window->add($hbox);
$tooltips = new GtkTooltips();
$tooltips->set_tip($button1, $label->get_text());
$button2->set_label("Button 2");
$button2->set_events(MOUSE_EVENTS);
$button2->connect_simple("button-press-event", "changeLabelText", $label, "Ardvark", $tooltips, $button1);
$button3->set_label("Button 3");
$button3->set_events(MOUSE_EVENTS);
$button3->connect_simple("button-press-event", "changeLabelText", $label, "Anteater", $tooltips, $button1);
$button1->set_size_request(28, 100);
$button1->add($label);
$hbox->pack_start($button1);
$hbox->add($button2);
$hbox->add($button3);
$window->show_all();
gtk::main();
?>
-- PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ NOD32 1.1356 (20060108) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com