import tkinter def hello_world(): print('hello world') if __name__ == '__main__': root = tkinter.Tk() frame = tkinter.Frame(root) frame.pack() button = tkinter.Button(frame, text='Hello World', command=hello_world) button.pack(side='top') # run all pending tasks, so that the window is shown up in python 3.6 root.update_idletasks() input('Press enter to exit') # block the console