import
pygtk
pygtk.require(
"2.0"
)
import
gtk
class
MainWin:
def
__init__(
self
):
main_win
=
gtk.Window(gtk.WINDOW_TOPLEVEL)
main_win.set_title(
"Ejemplo 1"
)
main_win.connect(
"destroy"
,
self
.on_quit)
vbox
=
gtk.VBox(
False
,
5
)
self
.label
=
gtk.Label(
"Hola mundo"
)
self
.entry
=
gtk.Entry()
self
.entry.connect(
"activate"
,
self
.on_button1_clicked)
button
=
gtk.Button(stock
=
gtk.STOCK_OK)
button.connect(
"clicked"
,
self
.on_button1_clicked)
vbox.add(
self
.label)
vbox.pack_start(
self
.entry,
True
,
True
,
0
)
vbox.pack_start(button,
False
,
False
,
0
)
main_win.add(vbox)
main_win.show_all()
def
on_button1_clicked(
self
, widget):
texto
=
self
.entry.get_text()
self
.label.set_text(
"Hola %s"
%
texto)
def
on_quit(
self
, widget):
gtk.main_quit()
if
__name__
=
=
"__main__"
:
MainWin()
gtk.main()
No hay comentarios:
Publicar un comentario