Pygtk: invert text widget colors

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

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

I tried everything, including widget.modify_fg and widget.modify_text , and yet it seems that nothing changes the color of the text in this text view.

Here is my textual code that 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 a text view with black bg ... I want this ... but the foreground text should be white.

Any ideas what I need to do?

+4
source share
1 answer

Found the answer. This is much simpler than I intended.

 # 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')) 

What all!!!

+5
source

Source: https://habr.com/ru/post/1299587/


All Articles