Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/11/2011, 14:06
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Ventanas desplegables Python

No uses gtk.Combo esta obsoleto, mejor usa gtk.ComboBox

Código Python:
Ver original
  1. import gtk
  2.  
  3. text = ["ejemplo", "ejemplo2","ejemplo3","ejemplo4"]
  4.  
  5.  
  6. class MyApp():
  7.  
  8.     def __init__(self):
  9.         window = gtk.Window()
  10.         window.set_border_width(0)
  11.         window.set_title("ventana desplegable")
  12.         window.set_size_request(300, 150)
  13.         window.set_resizable(False)
  14.  
  15.         self.combo = gtk.combo_box_entry_new_text()
  16.         for t in text:
  17.             self.combo.append_text(t)
  18.                
  19.         boton = gtk.Button(stock=gtk.STOCK_OK)
  20.         boton.connect("clicked", self.onClick)
  21.    
  22.         vbox = gtk.VBox()
  23.        
  24.         vbox.add(self.combo)
  25.         vbox.add(boton)
  26.        
  27.         window.add(vbox)
  28.         window.show_all()
  29.         window.connect("destroy", gtk.main_quit)
  30.        
  31.     def onClick(self, event, data=None):
  32.         print self.combo.get_active_text()
  33.                    
  34.  
  35. if __name__ == "__main__":
  36.     app = MyApp()
  37.     gtk.main()