#! /usr/bin/env python # -*- coding: utf-8 -*- """ Small program to try Tkinter. Online doc: https://docs.python.org/2/library/tkinter.html#a-simple-hello-world-program Credit: Lilian Besson for http://perso.crans.org/besson/cs101/solutions/examples/ License: GPLv3 """ import Tkinter class Application(Tkinter.Frame): """Test. """ def say_hi(self): """Called by the button 'Hello' in the app. """ print "Hi there, everyone!" def createWidgets(self): """Test. """ self.btn_quit = Tkinter.Button(self) self.btn_quit["text"] = "Quit" self.btn_quit["fg"] = "red" self.btn_quit["command"] = self.quit self.btn_quit.pack({"side": "left"}) self.btn_hi_there = Tkinter.Button(self) self.btn_hi_there["text"] = "Hello" self.btn_hi_there["command"] = self.say_hi self.btn_hi_there.pack({"side": "left"}) def __init__(self, master=None): Tkinter.Frame.__init__(self, master) self.pack() self.createWidgets() if __name__ == '__main__': root = Tkinter.Tk() app = Application(master=root) try: app.mainloop() root.destroy() except Tkinter.TclError: exit(1)