views:

245

answers:

1

I finally managed to change the background of a textview widget in pygtk. Turns out I needed to use the widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0, 0, 0)) That results in the desired black background.

Now, the rest of the problem... Now I want to change the text color to white.

I have tried everything including widget.modify_fg and widget.modify_text and yet, Nothing seems to change the color of the text in this textview.

Here is my code to the textview I have now

import gtk
tv = gtk.TextView()
tv.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(0,0,0,0))
tv.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color(255,255,255,0))

This results in the textview with the black bg... I want that... but the forground text needs to be white.

Any ideas what I need to do?

A: 

Found the answer. It is much simpler than I was going.

# Textview with inverted colors
import gtk

tv = gtk.TextView()
tv.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
tv.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))

That's all!!!

M0E-lnx
It really depends what colours you started with to invert, doesn't it?
Ali A
Yes, but gtk.Textview normally defaults to a white background with black text. Much like any other text editor widget.
M0E-lnx