Sender: frechot at labri.fr Message-ID: <3ABF7385.6E77C227 at labri.fr> Date: Mon, 26 Mar 2001 18:51:17 +0200 From: Jocelyn =?iso-8859-1?Q?Fr=E9chot?= MIME-Version: 1.0 To: lablgtk at kaba.or.jp Subject: colors, fonts and tree items References: <3AB24BB2.47DEE112 at labri.u-bordeaux.fr> <20010317122620K.garrigue at kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Jacques Garrigue wrote: > > From: Jocelyn Fréchot > > > My problem is : > > > > I would like to set the background color of (the label of) > > a tree_item object. And I don't know how... > > Here is a modification to testgtk.ml, > that will change the background color of the second element in the > created tree. You just have to build the alignment and the label by hand, > and add an event_box to change the color. > > let rec create_subtree (item : GTree.tree_item) level nb_item_max > recursion_level_max = > if level = recursion_level_max then () > else begin > let item_subtree = GTree.tree () in > for nb_item = 1 to nb_item_max do > let item_new = GTree.tree_item ~packing:(item_subtree#insert ~pos:0) ()in > let ali = GBin.alignment ~x:0. ~xscale:0. ~packing:item_new#add () in > let label = GMisc.label ~packing:ali#add > ~text:("item" ^ string_of_int level ^ "-" ^ string_of_int nb_item) () > in > if nb_item = 2 then begin > ali#remove label#coerce; > let evbox = GBin.event_box ~packing:ali#add () in > evbox#add label#coerce; > let style = evbox#misc#style#copy in > evbox#misc#set_style style; > style#set_bg [`NORMAL, `NAME "green"]; > end; > create_subtree item_new (level + 1) nb_item_max recursion_level_max; > done; > item # set_subtree item_subtree > end All right, it works very well. I like these pretty colors :) I understood the code (I think...) but now, I try to change foreground color and font. And, of course, my poor tree remains like it has always been (except for the funny background colors!). Could someone give me a begining of answer? Thanks, Jocelyn Fréchot. PS: I'm not on the mailing list.