Re: setting widget color
- From: muppet <scott asofyet org>
- To: Carl Nygard <cjnygard fast net>
- Cc: gtk-perl-list gnome org
- Subject: Re: setting widget color
- Date: Tue, 16 Mar 2004 23:19:21 -0500
On Tuesday, March 16, 2004, at 01:36 PM, Carl Nygard wrote:
I need to set a label's color (fg, bg, either way) on the fly, do
different colors depending on state.
...
Can someone point me to code that shows how to do this? All the
archive examples seem to be specific to Gtk-perl, not Gtk2-perl.
With the standard disclaimers and admonishments that you shouldn't
change styles and colors with a *really* good reason to do so, since
that's the theme engine's domain and you can mess up your ui for
colorblind people and depending on color is bad for blind people using
screen readers and all that stuff...
/me catches breath
This is easier in gtk+-2.x.
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-
modify-bg
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/
Widget.html#_widget_modify_bg_st
e.g.
$dlg = Gtk2::Dialog->new;
$ebox = Gtk2::EventBox->new;
$label = Gtk2::Label->new ('hi there');
$ebox->add ($label);
$dlg->vbox->add ($ebox);
# turn the background bright red
$ebox->modify_bg ('normal', Gtk2::Gdk::Color->new (65535, 0, 0));
# turn the text bright green
$label->modify_fg ('normal', Gtk2::Gdk::Color->new (0, 65535, 0));
$dlg->show_all;
Gtk2->main;
the 'normal' there was for the normal widget state. there are five
state types, which are probably not the ones to which you were
referring:
http://developer.gnome.org/doc/API/2.0/gtk/gtk-Standard-
Enumerations.html#GtkStateType to do that code right for a generic
app, you'd have to set colors for more than just 'normal'.
but remember that you're not supposed to do this.
--
"it's hard to be eventful when you have this much style."
- me, rationalizing yet another night of sitting at home.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]