summaryrefslogtreecommitdiffstats
path: root/Doc/library/tkinter.rst
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-03-15 04:41:23 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-03-15 04:41:23 (GMT)
commitd3d7c903e6ee86d54d7fdb720ce81f24ee75e316 (patch)
tree2a66ec931ff518920894265d52fad22877fcfa93 /Doc/library/tkinter.rst
parent7b51b8de3809c59ef3cf1baea51c2d63da1c8752 (diff)
downloadcpython-d3d7c903e6ee86d54d7fdb720ce81f24ee75e316.zip
cpython-d3d7c903e6ee86d54d7fdb720ce81f24ee75e316.tar.gz
cpython-d3d7c903e6ee86d54d7fdb720ce81f24ee75e316.tar.bz2
Closes issue #14163 - tkinter: problems with hello doc example
Diffstat (limited to 'Doc/library/tkinter.rst')
-rw-r--r--Doc/library/tkinter.rst53
1 files changed, 24 insertions, 29 deletions
diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
index ae5635f..62eedff 100644
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -179,35 +179,30 @@ A Simple Hello World Program
::
- from tkinter import *
-
- class Application(Frame):
- def say_hi(self):
- print("hi there, everyone!")
-
- def createWidgets(self):
- self.QUIT = Button(self)
- self.QUIT["text"] = "QUIT"
- self.QUIT["fg"] = "red"
- self.QUIT["command"] = self.quit
-
- self.QUIT.pack({"side": "left"})
-
- self.hi_there = Button(self)
- self.hi_there["text"] = "Hello",
- self.hi_there["command"] = self.say_hi
-
- self.hi_there.pack({"side": "left"})
-
- def __init__(self, master=None):
- Frame.__init__(self, master)
- self.pack()
- self.createWidgets()
-
- root = Tk()
- app = Application(master=root)
- app.mainloop()
- root.destroy()
+ import tkinter as tk
+
+ class Application(tk.Frame):
+ def __init__(self, master=None):
+ tk.Frame.__init__(self, master)
+ self.pack()
+ self.createWidgets()
+
+ def createWidgets(self):
+ self.hi_there = tk.Button(self)
+ self.hi_there["text"] = "Hello World\n(click me)"
+ self.hi_there["command"] = self.say_hi
+ self.hi_there.pack(side="top")
+
+ self.QUIT = tk.Button(self, text = "QUIT", fg = "red",
+ command = root.destroy)
+ self.QUIT.pack(side = "bottom")
+
+ def say_hi(self):
+ print("hi there, everyone!")
+
+ root = tk.Tk()
+ app = Application(master=root)
+ app.mainloop()
A (Very) Quick Look at Tcl/Tk