On Wed, 5 Mar 2014 14:08:51 +0100
"Thomas Funk" <t.f...@web.de> wrote:

>"Emmanuele Bassi" <eba...@gmail.com> wrote:

>> don't. GtkTooltips has long since been deprecated, and should never be
>> used in newly written code:
>> 
>>     https://developer.gnome.org/gtk2/stable/GtkTooltips.html
>> 
>> you should simply set the tooltip through the
>> Gtk2::Widget::set_tooltip_text() method (or set_tooltip_markup()
>> method, if you want to use Pango markup in the tooltips).
>
>I tried this already but it has the same behaviour - tooltip is shown
>around the corners of a widget only :-(
>
>
>Could you provide a perl snippet so that I understand what I have to do?
>
>Thanks,

>Thomas

Hi, I don't want to contradict Emmanuelle Bassi, about
it being deprecated, but here is a script that works
with Tooltips.

The glitch as far as I remember, was that tooltip needed 
an eventbox on non-windowed widgets, like Labels. I hope this
example helps.

#!/usr/bin/perl
use warnings;
use strict;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

my $window = Gtk2::Window->new('toplevel');
$window->set_title('Z');
$window ->signal_connect( 'destroy' => \&delete_event );
$window->set_border_width(10);
$window->set_size_request(300,200);

my $vbox = Gtk2::VBox->new( FALSE, 6 );
$window->add($vbox);
$vbox->set_border_width(2);

my $hbox= Gtk2::HBox->new( FALSE, 6 );
$vbox->pack_end($hbox,FALSE,FALSE,0);
$hbox->set_border_width(2);

my $frame0 = Gtk2::Frame->new('Controls');
$vbox->pack_end( $frame0, FALSE, FALSE, 0 );
$frame0->set_border_width(3);

$vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0);

my $hbox0 = Gtk2::HBox->new( FALSE, 6 );
$frame0->add($hbox0);
$hbox0->set_border_width(3);

my $button = Gtk2::Button->new_from_stock('gtk-quit');
$hbox0->pack_end( $button, FALSE, FALSE, 0 );
$button->signal_connect( clicked => \&delete_event );

my $frame1 = Gtk2::Frame->new('Some Frame');
$vbox->pack_start( $frame1, FALSE, FALSE, 0 );
$frame1->set_border_width(3);


#labels don't respond to tooltips, since they have no
#underlying window, so we must put the label in an event box.
my $label =  Gtk2::Label->new( "This label is just for you\n" );
$label->set_justify('left');

my $eventb1 = Gtk2::EventBox->new();
$eventb1->set_border_width(3);
$eventb1->add($label);

$frame1->add($eventb1);

my $tooltip0 = Gtk2::Tooltips->new;
my $tip_text = 'Just for you';
$tooltip0->set_tip($eventb1, $tip_text, undef);

my $tooltip1 = Gtk2::Tooltips->new;
my $tip_text1 = 'Just Another Exit Button';
$tooltip1->set_tip($button, $tip_text1, undef);

$window->show_all();
Gtk2->main;
#####################################
sub delete_event {
Gtk2->main_quit;
return FALSE;
}  

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to