Re: Label Colors

From: Date: Mon, 13 Dec 2004 12:44:44 +0000
Subject: Re: Label Colors
References: 1 2 3 4  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5351@lists.php.net to get a copy of this message
This work for me: <? $col1=&new gdkcolor('red'); $st1 = $entry1->style; $st1 = $st1->copy(); # you must do this fir a good results don''t ask me why but it won't work if you don't copy it $st1->fg[0]=$col1; $entry1->set_style($st1); $col=&new gdkcolor('green'); $st2 = $entry2->style; $st2 = $st2->copy(); $st2->fg[0]=$col2; $entry2->set_style($st2); ?> regards nathan On Mon, 13 Dec 2004 00:59:21 +0100, Gonzalo Monzón <gmc@serveisw3.net> wrote: > Steven Norder wrote: > > > > > Ok i don't excatly understand what you mean but i tried it with your code > > and still does the same thing. > > basicly i want $label[1] to be blue and $label[2] to be orange. and > > they all > > turn orange when i do it > > > > Steven > > > > ----- Original Message ----- From: "Gonzalo Monzón" <gmc@serveisw3.net> > > To: <php-gtk-general@lists.php.net> > > Sent: Sunday, December 12, 2004 4:21 PM > > Subject: Re: [PHP-GTK] Label Colors > > > > > >> Steven Norder wrote: > >> > >>> I have spent the last day or so trying to figure out how to set the > >>> color/font on a label > >>> which come to find out it was in the main docs just couldn't find it > >>> right away. > >>> My question is, is there any way to make to the text of two > >>> different labels different colors? > >>> every way i try to do it it seems to just change all the labels to > >>> same color/font > >>> this is my latest try and i get nothing they are all the same color > >>> they all go orange > >>> $label[1] = &new GtkLabel("This is my label 1"); > >>> $label[2] = &new GtkLabel("This is my label 2"); > >>> $style[1] = $label[1]->get_style(); > >>> $font[1] = > >>> gdk::font_load("-*-helvetica-medium-r-normal--*-180-*-*-*-*-*-*"); > >>> $style[1]->font = $font[1]; > >>> $color[1] = &new GdkColor( 'blue');; > >>> $style[1]->fg[GTK_STATE_NORMAL] = $color[1]; > >>> $label[1]->set_style( $style[1]); > >>> > >>> $style[2] = $label[2]->get_style(); > >>> $font[2] = > >>> gdk::font_load("-*-helvetica-medium-r-normal--*-180-*-*-*-*-*-*"); > >>> $style[2]->font = $font[2]; > >>> $color[2] = &new GdkColor( 'orange');; > >>> $style[2]->fg[GTK_STATE_NORMAL] = $color[2]; > >>> $label[2]->set_style( $style[2]); > >>> any help would be very very nice i noticed someone asked this > >>> question like 6 months ago but i couldnt' find a response > >>> if it is somewhere on the site i am sorry for missing it but i have > >>> looked everywhere i can and browsed the archives of this mailing list.. > >>> Steven > >>> > >>> ------------------------------------------------------------------------ > >>> > >>> > >>> No virus found in this outgoing message. > >>> Checked by AVG Anti-Virus. > >>> Version: 7.0.289 / Virus Database: 265.4.8 - Release Date: 12/8/2004 > >>> > >>> > >> Hi Steven! > >> > >> I think your're not doing it well... you must do a copy of the style > >> ie. getting it from the gtk::widget_get_default_style or with > >> $widget->get_style and then doing a copy of it before setting it > >> modified... > >> > >> These two code pieces work well for me: > >> > >> First example: getting the style from gtk directly... > >> > >> $label4=&new GtkLabel(' Pegar Ctrl+V'); > >> $appStyle = gtk::widget_get_default_style(); > >> $appStyle->fg[GTK_STATE_NORMAL]=$color; > >> $label4->set_style($appStyle); > >> > >> or another way, getting the actual widget's style: > >> > >> $cstyle=$this->en_reloj->get_style(); > >> $bstyle=$cstyle->copy(); > >> > >> $bfont=gdk::font_load("-*-arial-bold-r-normal--*-120-*-*-*-*-iso8859-1"); > >> > >> $bstyle->font=$bfont; > >> $negro = &new GdkColor('#000000'); > >> $bstyle->fg[GTK_STATE_INSENSITIVE] = $negro; > >> $this->en_reloj->set_style($bstyle); > >> > >> Sincerely, > >> Gonzalo Monzón > >> > >> -- > >> PHP-GTK General Mailing List (http://gtk.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > >> > >> > >> > >> -- > >> No virus found in this incoming message. > >> Checked by AVG Anti-Virus. > >> Version: 7.0.296 / Virus Database: 265.5.0 - Release Date: 12/9/2004 > >> > >> > > > > > > > Hi Steven! > > I had a deeper look into my code and I noticed it was used in hacking > styles to change the style of a widget when using themes... but i do > something wrong too, It makes something very strange: > > Changing the color results in a font-size change (???) too for the > widget (I use "themes" and the theme I use uses a default text for the > labels of 10px size and changing the style color as I do in my code > results in a non expected 12px size font printed on the label... and > only changes the color if it's black -in theme was darkblue-, other > colors doesn't seem to be working... and now I don't know why) > > So changing colors as you said does not work with my code. > > I'll need to take a look to it, anyway... I thought it was working in > my code... and now I notice that its not true... i will post a reply if > do I find a working code... > > > > Sincerely, > Gonzalo Monzón > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -- Malk0 -- venez discuter php-gtk en francais ici http://mk0phpgtk.xgarreau.org

« previous php.gtk.general (#5351) next »