Bueno tienes varios errores, pero principalmente es por que nunca enlazas tu combobox a un evento.
Código Python:
Ver originalimport pygtk
pygtk.require('2.0')
import gtk
import os
class Prueba:
path = '/ruta/'
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_resizable(True)
self.window.set_title("Temas")
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.set_border_width(0)
self.window.set_size_request(550, 600)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.fixed = gtk.Fixed()
text = next(os.walk(self.path))[1]
text.sort(key=lambda x: x.upper())
combox_themas = gtk.combo_box_new_text()
combox_themas.set_size_request(180, 35)
for t in text:
combox_themas.append_text(t)
self.fixed.put(combox_themas, 320, 80)
combox_themas.show()
combox_themas.connect('changed', self.changed_cb)
self.window.add(self.fixed)
self.window.show_all()
self.window.show()
def changed_cb(self, combobox):
if combobox.get_active_text():
filename = self.path + combobox.get_active_text() + '/background.png'
if os.path.exists(filename):
file_buffer = gtk.gdk.pixbuf_new_from_file_at_size(filename, 417, 270)
self.image_theme = gtk.image_new_from_pixbuf(file_buffer)
self.fixed.put(self.image_theme, 71, 163)
self.image_theme.show()
else:
# Put some error here
pass
def delete_event(self, widget, event, data=None):
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def main():
gtk.main()
return 0
if __name__ == "__main__":
Prueba()
main()