import sys from tkinter import Button, mainloop x = Button( text='Apasa', command=(lambda:sys.stdout.write('Hello\n'))) x.pack() mainloop() # optional