[Python-checkins] cpython (3.5): Issue #27455: Improve examples in tkinter documentation

berker.peksag python-checkins at python.org
Thu Jul 14 00:32:53 EDT 2016


https://hg.python.org/cpython/rev/453a88a41a58
changeset:   102346:453a88a41a58
branch:      3.5
parent:      102343:0fbf3b88eed8
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Thu Jul 14 07:32:43 2016 +0300
summary:
  Issue #27455: Improve examples in tkinter documentation

Patch by John Hagen.

files:
  Doc/library/tkinter.rst |  26 +++++++++++++-------------
  1 files changed, 13 insertions(+), 13 deletions(-)


diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -199,19 +199,19 @@
 
     class Application(tk.Frame):
         def __init__(self, master=None):
-            tk.Frame.__init__(self, master)
+            super().__init__(master)
             self.pack()
-            self.createWidgets()
+            self.create_widgets()
 
-        def createWidgets(self):
+        def create_widgets(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",
+            self.quit = tk.Button(self, text="QUIT", fg="red",
                                   command=root.destroy)
-            self.QUIT.pack(side="bottom")
+            self.quit.pack(side="bottom")
 
         def say_hi(self):
             print("hi there, everyone!")
@@ -536,7 +536,7 @@
 
    class App(Frame):
        def __init__(self, master=None):
-           Frame.__init__(self, master)
+           super().__init__(master)
            self.pack()
 
            self.entrythingy = Entry()
@@ -581,13 +581,13 @@
 
 Here are some examples of typical usage::
 
-   from tkinter import *
-   class App(Frame):
+   import tkinter as tk
+
+   class App(tk.Frame):
        def __init__(self, master=None):
-           Frame.__init__(self, master)
+           super().__init__(master)
            self.pack()
 
-
    # create the application
    myapp = App()
 
@@ -708,13 +708,13 @@
 
 For example::
 
-   def turnRed(self, event):
+   def turn_red(self, event):
        event.widget["activeforeground"] = "red"
 
-   self.button.bind("<Enter>", self.turnRed)
+   self.button.bind("<Enter>", self.turn_red)
 
 Notice how the widget field of the event is being accessed in the
-:meth:`turnRed` callback.  This field contains the widget that caught the X
+``turn_red()`` callback.  This field contains the widget that caught the X
 event.  The following table lists the other event fields you can access, and how
 they are denoted in Tk, which can be useful when referring to the Tk man pages.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list