Just a note on colour allocation.

Previously, before I had added colourmap support to pygtk, I hada
color_alloc function.  As the first argument it took a widget or style or
window, and the other arguments would specify the colour in one of three
ways:
  colour = color_alloc(wid, 'red')  # allocate red
  colour = color_alloc(wid, 0xff0000)
  colour = color_alloc(wid, 0xffff, 0, 0)  # 16 bit RGB elements

That function is now deprecated.  The correct way of allocating colours
for use in text widget or for drawing is to use the GdkColormap type's
alloc method.  You can get the colourmap from windows, styles and widgets
as follows:
  cmap = style.colormap
  cmap = window.colormap
  cmap = widget.get_colormap()
And you can allocate colours in two ways:
  colour = cmap.alloc('red')   # a string name.  '#ff0000' would also give red
  colour = cmap.alloc(0xffff, 0, 0) # 16 bit RGB elements

It is prefered that you use GdkColormap.alloc instead of color_alloc.  I
hope that this is helpful.

James Henstridge.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Fri, 5 Feb 1999, Sam Tannous wrote:

> I'm not sure if this made it out (I didn't see
> it sent out last night)...
> 
> -------------------------------------
> OK I give up.  After a few hours of twiddling
> I can't seem to figure out how to insert red
> text on a white background in a GtkText widget.
> 
> Would anyone be kind enough to supply me a few lines
> of code?  
> 
> Here's what I've tried which doesn't work:
> 
> ---------------------------------
> #       text.insert_defaults(b)
> #       font = "lucidasanstypewriter-12"
> #       realfont = load_font(font)
>         style = text.get_style()
>         print "colormap = ",style.colormap
>         red = colour_alloc("0xFFFF", "0x0000", "0x0000")
> #        style.fg =  ["0", "0xFFFF", "0x0000", "0x0000"]
> #        black = [0, 0x0000, 0x0000, 0x0000]
> #        white = [0, 0xFFFF, 0xFFFF, 0xFFFF]
> #        red = [0, 0xFFFF, 0x0000, 0x0000]  
> #        green = [0, 0x0000, 0xFFFF, 0x0000]
> #        blue = [0, 0x0000, 0x0000, 0xFFFF] 
> #        cyan = [0, 0x0000, 0xFFFF, 0xFFFF] 
> #        magenta = 0, 0xFFFF, 0x0000, 0xFFFF]
> #        yellow = [0, 0xFFFF, 0xFFFF, 0x0000]
> 
>         text.insert(style.font,style.black,red,b)
> ---------------------------------
> 
> Thanks,
> Sam "I promise to add lots of documentation when I finish" Tannous
> 
> ----- End forwarded message -----
> 
> -- 
> ===================================================
> Sam Tannous, NSA    ciscoSystems, RTP, NC
> [EMAIL PROTECTED]  919.472.2541  page:800.365.4578
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to