From 04c9daf21ae628a920ec338e3551cdd0dc84754b Mon Sep 17 00:00:00 2001 From: johnthagen Date: Tue, 5 Jul 2016 08:59:25 -0400 Subject: [PATCH 1/2] Fix tkinter docs to be PEP8 compliant. --- Doc/library/tkinter.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index 130aafe..6400369 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -197,21 +197,22 @@ A Simple Hello World Program import tkinter as tk + class Application(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, 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!") @@ -552,7 +553,7 @@ For example:: # and here we get a callback when the user hits return. # we will have the program print out the value of the # application variable when the user hits return - self.entrythingy.bind('', + self.entrythingy.bind("", self.print_contents) def print_contents(self, event): @@ -582,6 +583,8 @@ part of the implementation, and not an interface to Tk functionality. Here are some examples of typical usage:: from tkinter import * + + class App(Frame): def __init__(self, master=None): Frame.__init__(self, master) @@ -687,7 +690,7 @@ The bind method from the widget command allows you to watch for certain events and to have a callback function trigger when that event type occurs. The form of the bind method is:: - def bind(self, sequence, func, add=''): + def bind(self, sequence, func, add=""): where: @@ -708,7 +711,7 @@ add For example:: - def turnRed(self, event): + def turn_red(self, event): event.widget["activeforeground"] = "red" self.button.bind("", self.turnRed) -- 2.9.0.windows.1 From 0cd76448648ae1dd23a5dd8bc3a57cc24f111299 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Tue, 5 Jul 2016 09:06:36 -0400 Subject: [PATCH 2/2] Fix missing method refactor. --- Doc/library/tkinter.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index 6400369..bf740ef 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -714,10 +714,10 @@ For example:: def turn_red(self, event): event.widget["activeforeground"] = "red" - self.button.bind("", self.turnRed) + self.button.bind("", 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 +:meth:`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. -- 2.9.0.windows.1