pygtk: invert colors of a textview Widget
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?
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!!!
You could also use gtk.gdk.Color("#FFFFFF")
for white.
精彩评论