Not sure which documentation you're following, doesn't seem to be correct thought. The following works:
use strict;
use warnings;
use Gtk2;
Gtk2->init;
my $window = Gtk2::Window->new ('toplevel');
my $bar1 = Gtk2::RadioButton->new (undef, 'Original Label');
$window->add ($bar1);
$bar1->set_label('Updated Label');
$window->show_all;
Gtk2->main;
| [reply] [d/l] |
I read what documentation I found and I checked out the ManPage for Gtk2::RadioButton and couldn't find anything about using
Label Widgets with this. But I figured maybe it was possible since most of the documentation I found for Gtk2 doesn't always
show every single method that each particular widget is capable of using. For instance the info I found for some of the Widgets
don't include some of the methods like; "modify_bg()" and "modify_fg()", I found were missing from a few of the Widgets
Method's lists...
This is something that can be bothersome at first, but it’s actually useful. The widgets are organised into a hierarchy, and so, widget types deep in the hierarchy will have many methods inherited from higher up. Since everything visible is a Gtk2::Widget you should look at that man page too. Sometimes also somewhere inbetween (eg. Gtk2::Editable for Gtk2::Entry, or Gtk2::ToggleButton for Gtk2::RadioButton). These hierarchical relationships are written in every piece of documentation in the Gtk2 module.
What’s slightly more annoying is the lack of explanations under the methods, so you’ll need to go to eg. GtkRadioButton and read their explanations there.
As for the actual question about colouring: indeed, some widgets, including Gtk2::Label don’t have a full drawn area and they’re always transparent — you’ll need to wrap them in something that does, for example a Gtk2::EventBox. Then you’ll be able to colour the background of that and it will be visible through the Label.
Update: Added link to GtkLabel rendering info.
| [reply] [d/l] [select] |
Hey Guys, thank you both for the reply!
Yea I decided to just use plain-text instead, orignally I was trying to use a "Gtk2::Label" as the RadioButton's label.
I guess I was thinking "set_label()" was actually for adding a Label Widget... But I was wrong, Duhh lol...
And yes Ralesk, your absolutely right about the documentation not having any good explanations for each Widget. If you
go to the Sourceforge page for Perl::Gtk2 you'll see what I'm talking about. And when you check each object they only
give you what Methods it has and what options go with those Methods, but no explanations at all. Which is EXACTLY the
same information you see in each Widget's Manpage from the CLI...
        HERE--> http://gtk2-perl.sourceforge.net/doc/pod/index.html
But anyway, I'm pretty much done with the aesthetics of the UI so I don't have to create anymore widgets... Finally...
Thanks again Guys for the help and suggestions with this, much appreciated!
Thanks Again,
Matt
| [reply] |