from __future__ import print_function # # Create a GUI with a label. # try: import Tkinter except ImportError: import tkinter as Tkinter # We use the same pattern as tkinter_button3.py def main(): app = Tkinter.Frame() app.grid() make_ui(app) app.mainloop() # "make_ui" is the almost the same as in tkinter_button3.py. # Here, we create a "label" widget before the buttons. We # also place the label above the buttons by putting it in # row 0, while the buttons go in row 1. The label spans # both button columns because we specified "columnspan" as # 2 when we "grid"ed the label. def make_ui(app): def quit_cb(app=app): app.quit() def die(): raise SystemExit(1) label = Tkinter.Label(app, text="Here's a label") label.grid(row=0, column=0, columnspan=2) button = Tkinter.Button(app, text="Quit", command=quit_cb) button.grid(row=1, column=0) button = Tkinter.Button(app, text="Die", command=die) button.grid(row=1, column=1) if __name__ == "__main__": main() print("Finished")