Código Python:
Ver original
#!/usr/bin/env python # -*- coding: utf-8 -*- import gtk class Programa: def __init__(self): self.ventana = gtk.Window(gtk.WINDOW_TOPLEVEL) self.ventana.connect('delete_event', self.delete_event) self.ventana.connect('destroy', self.destroy) self.ventana.set_title('Título de la ventana') self.ventana.set_default_size(440, 250) self.ventana.set_border_width(50) self.caja_v = gtk.VBox(True, 0) self.etiqueta = gtk.Label('Bienvenido:') self.entrada = gtk.Entry(20) self.botonera_h = gtk.HButtonBox() self.boton_aplicar = gtk.Button(stock=gtk.STOCK_APPLY) self.boton_aplicar.connect('clicked', self.clicked, 'Botón Aplicar') self.boton_cancelar = gtk.Button(stock=gtk.STOCK_CANCEL) self.boton_cancelar.connect('clicked', self.clicked, 'Botón Cancelar') self.boton_cancelar.connect("clicked", self.delete_event) self.ventana.add(self.caja_v) self.caja_v.pack_start(self.etiqueta, True, True, 0) self.caja_v.pack_start(self.entrada, True, True, 0) self.caja_v.pack_start(self.botonera_h, True, True, 0) self.botonera_h.add(self.boton_aplicar) self.botonera_h.add(self.boton_cancelar) def main(self): gtk.main() def show(self): self.ventana.show_all() def delete_event(self, widget, data=None): print 'delete_event' return False def destroy(self, widget, data=None): print 'destroy' gtk.main_quit() def clicked(self, widget, data=None): print data if __name__ == '__main__': programa = Programa() programa.show() programa.main()