# Simple button program, with actions, like java SimpleButton2 # Weird import for compatibility across Python 2 and Python 3 try: import tkinter except ImportError: import Tkinter as tkinter # Callback function for our button, # must define it before we refer to it below def myCallback(): print ("Button was pushed") # Create main frame top = tkinter.Tk() # Put our button in the main frame # and set button's properties b1 = tkinter.Button (top) b1["text"] = "Push me" b1["command"] = myCallback b1.pack() # Start the main GUI loop top.mainloop()