Curso de Programación en Python/Input-9

De WikiCabal
Ir a la navegación Ir a la búsqueda

Input-9.py

 1 #!/usr/bin/python3
 2 #-*-coding: utf-8 -*-
 3 
 4 import tkinter as tk
 5 
 6 class Application( tk.Frame ):
 7   def __init__( self, master=None ):
 8     tk.Frame.__init__( self, master )
 9     self.pack()
10     self.createWidgets()
11 
12   def createWidgets( self ):
13     self.hi_there = tk.Button( self )
14     self.hi_there["text"] = "Hola Mundo\n( Da click aquí )"
15     self.hi_there["command"] = self.say_hi
16     self.hi_there.pack( side="top" )
17     self.QUIT = tk.Button( self, text="Terminar", fg="red",
18                                             command=root.destroy )
19     self.QUIT.pack( side="bottom" )
20 
21   def say_hi( self ):
22     print( "Saludos a todos!" )
23 
24 root = tk.Tk()
25 app = Application( master=root )
26 app.mainloop()

Resultado

Input-9.png