Re: How to setup label foreground colour ?




Hi, 

I need to setup colour for label widget, (a couple of labels). I want 
to use my own style different from default only with colour. 

My piece of code is :

...
$style =  $label->get_style();
$newstyle = $style;
$newstyle->{'fg'} = $color; # the color is gdk colour allocated above
$label->set_style($newstyle); 
...

And it does not work ! :( 

Please, any suggestion, will be fine !



Styles contain arrays of fg/bg colors: a color per a state.
So you should use the function
  Gtk::Gdk::Color $style->fg ($state, $new_color)

Try the following:
  ...
  $style = $label->get_style();
  $newstyle = $style->copy(); 
  $newstyle->fg('normal', $color); 
  $label->set_style($style);
  ...

-- 
Best regards
Pavel.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]