Curso de Programación en Python/Input-8

De WikiCabal
Saltar a: navegación, buscar

Input-8.py

#!/usr/bin/python3
#-*-coding: utf-8 -*-

from tkinter import *

class MyDialog:
  def __init__( self, parent ):
    top = self.top = Toplevel( parent )
    Label( top, text="Valor" ).pack()
    self.e = Entry( top )
    self.e.pack( padx=5 )
    b = Button( top, text="Listo", command=self.ok )
    b.pack( pady=5 )

  def ok( self ):
    print( "El valor es:", self.e.get() )
    self.top.destroy()

root = Tk()
Button( root, text="Hola!" ).pack()
root.update()

d = MyDialog( root )

root.wait_window( d.top )

Resultado

Input-8.png