Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygtk: invert colors of a textview Widget

Tags:

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?

like image 336
M0E-lnx Avatar asked Jan 27 '10 20:01

M0E-lnx


1 Answers

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!!!

like image 187
M0E-lnx Avatar answered Nov 15 '22 07:11

M0E-lnx