2012-07-27 17 views
5

sto creando un semplice terminale in python usando vte.Terminal. voglio avere un certo livello di trasparenza sullo sfondo del terminale ma set_opacity non funziona. ma funziona in terminator e altri terminali.come abilitare la trasparenza in vte.Terminal

window.set_opacity rende trasparente l'intera finestra ma non voglio che il pipistrello del titolo sia trasparente. ecco il codice.

#!/usr/bin/env python 

import vte 
import gtk 
import pango 
import os 
import signal 

window = gtk.Window(gtk.WINDOW_TOPLEVEL) 
window.connect('destroy', lambda w: gtk.main_quit()) 
# initial window size 
window.resize(640, 480) 

terminal = vte.Terminal() 
terminal.connect("child-exited", lambda w: gtk.main_quit()) 

# here you can set backscroll buffer 
terminal.set_scrollback_lines(5000) 
# encoding for console 
terminal.set_encoding("UTF-8") 
terminal.set_cursor_blinks(False) 

# here you can set background image 
#terminal.set_background_image_file("some/background/picture/here") 

# transparency 
terminal.set_opacity (45000) 
# font for terminal 
font = pango.FontDescription() 
font.set_family("Ubuntu Mono") 
# font size 
font.set_size(11 * pango.SCALE) 
font.set_weight(pango.WEIGHT_NORMAL) 
font.set_stretch(pango.STRETCH_NORMAL) 

terminal.set_font_full(font, True) 

child_pid = terminal.fork_command() 

scroll = gtk.ScrolledWindow() 
scroll.set_policy(0,1) 
scroll.add_with_viewport(terminal) 

window.add(scroll) 
window.show_all() 

# This must be here! before gtk.main() 
# here you can set columns count (first param) 
terminal.set_size(500,0) 

try: 
    gtk.main() 
except KeyboardInterrupt: 
    pass 
+0

Hai mai ricevuto una risposta? Sto avendo lo stesso problema. – weberc2

risposta

0

Il seguente snippet ha risolto questo problema.

colormap = window.get_screen().get_rgba_colormap() 
if colormap == None: 
    colormap = window.get_screen().get_rgb_colormap() 
gtk.widget_set_default_colormap(colormap) 

This is how the window looks

sebbene i endded utilizzando Vala per il programma e aveva una semplice funzione chiamata set_visual.

Spero che questo aiuti

+0

Stavo giocando con questo ... Posso rendere il terminale di per sé trasparente, ma non appena metto una ScrolledWindow tra la finestra principale e il widget del terminale, diventa nuovamente opaco, anche se chiamo ScrolledWindow.set_opacity (0). Sto anche usando Vala. – weberc2

Problemi correlati