I have little problem with a GtkText widget and GdkColor.
Please look at the code and say if the code is correct or not.
When I insert a colored text with "GtkText.insert (font, fg, bg, string)" it's only 
displayed
as black and white. And I can't figure it out.

--- PYTHON CODE ---
#!/usr/bin/env python

from gtk import *
from parser import *
from keyword import *

text = ''
token = ''

def process (*args):
        global text, token, win

        keyword = load_font ('-misc-fixed-bold-r-normal-*-*-120-*-*-c-*-iso8859-1')
        default = load_font ('-misc-fixed-medium-r-normal-*-*-120-*-*-c-*-iso8859-1')
        
    blue = args[0].get_colormap().alloc (0, 0, 255)

        if (args[1].keyval == 65293):
                text = text + '\n'
                token = ''
                args[0].insert_defaults ('\n')
        else:
                if (args[1].keyval == 32):
                        text = text + args[1].string
                        args[0].insert_defaults (' ')
                        if iskeyword(token):
                                args[0].backward_delete (len(token) + 1)
                                args[0].insert (keyword, blue, None, token)
                                args[0].insert (default, blue, None, ' ')

                        token = ''
                else:
                        args[0].insert (default, blue, None, args[1].string)
                        text = text + args[1].string
                        token = token + args[1].string



        
        
win = GtkWindow (WINDOW_TOPLEVEL, 'Python Editor')
code = GtkText ()

code.connect ('key_press_event', process)

win.connect ('destroy', mainquit)
win.add (code)
win.set_default_size (400, 300)
win.show_all()

mainloop()


--
�zg�r Caner
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to