https://github.com/python/cpython/commit/c36dbac588e1d99975f285a874bb20e9f5040af4
commit: c36dbac588e1d99975f285a874bb20e9f5040af4
branch: master
author: Ankit Chandawala <ankitchandawala@gmail.com>
committer: GitHub <noreply@github.com>
date: 2020-08-03T00:03:48-04:00
summary:
bpo-41425: Make tkinter doc example runnable (GH-21706)
Co-authored-by: Ankit Chandawala <achandaw@amazon.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
files:
A Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
M Doc/library/tkinter.rst
diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
index 3d90b4be17c97..9f954255c8b30 100644
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -541,31 +541,35 @@ the variable, with no further intervention on your part.
For example::
- class App(Frame):
- def __init__(self, master=None):
+ import tkinter as tk
+
+ class App(tk.Frame):
+ def __init__(self, master):
super().__init__(master)
self.pack()
- self.entrythingy = Entry()
+ self.entrythingy = tk.Entry()
self.entrythingy.pack()
- # here is the application variable
- self.contents = StringVar()
- # set it to some value
+ # Create the application variable.
+ self.contents = tk.StringVar()
+ # Set it to some value.
self.contents.set("this is a variable")
- # tell the entry widget to watch this variable
+ # Tell the entry widget to watch this variable.
self.entrythingy["textvariable"] = self.contents
- # 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
+ # Define a callback for when the user hits return.
+ # It prints the current value of the variable.
self.entrythingy.bind('<Key-Return>',
- self.print_contents)
+ self.print_contents)
def print_contents(self, event):
- print("hi. contents of entry is now ---->",
+ print("Hi. The current entry content is:",
self.contents.get())
+ root = tk.Tk()
+ myapp = App(root)
+ myapp.mainloop()
The Window Manager
^^^^^^^^^^^^^^^^^^
@@ -860,4 +864,4 @@ use raw reads or ``os.read(file.fileno(), maxbytecount)``.
WRITABLE
EXCEPTION
- Constants used in the *mask* arguments.
\ No newline at end of file
+ Constants used in the *mask* arguments.
diff --git a/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst b/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
new file mode 100644
index 0000000000000..617df72faeb37
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
@@ -0,0 +1 @@
+Make tkinter doc example runnable.
_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
commit: c36dbac588e1d99975f285a874bb20e9f5040af4
branch: master
author: Ankit Chandawala <ankitchandawala@gmail.com>
committer: GitHub <noreply@github.com>
date: 2020-08-03T00:03:48-04:00
summary:
bpo-41425: Make tkinter doc example runnable (GH-21706)
Co-authored-by: Ankit Chandawala <achandaw@amazon.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
files:
A Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
M Doc/library/tkinter.rst
diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
index 3d90b4be17c97..9f954255c8b30 100644
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -541,31 +541,35 @@ the variable, with no further intervention on your part.
For example::
- class App(Frame):
- def __init__(self, master=None):
+ import tkinter as tk
+
+ class App(tk.Frame):
+ def __init__(self, master):
super().__init__(master)
self.pack()
- self.entrythingy = Entry()
+ self.entrythingy = tk.Entry()
self.entrythingy.pack()
- # here is the application variable
- self.contents = StringVar()
- # set it to some value
+ # Create the application variable.
+ self.contents = tk.StringVar()
+ # Set it to some value.
self.contents.set("this is a variable")
- # tell the entry widget to watch this variable
+ # Tell the entry widget to watch this variable.
self.entrythingy["textvariable"] = self.contents
- # 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
+ # Define a callback for when the user hits return.
+ # It prints the current value of the variable.
self.entrythingy.bind('<Key-Return>',
- self.print_contents)
+ self.print_contents)
def print_contents(self, event):
- print("hi. contents of entry is now ---->",
+ print("Hi. The current entry content is:",
self.contents.get())
+ root = tk.Tk()
+ myapp = App(root)
+ myapp.mainloop()
The Window Manager
^^^^^^^^^^^^^^^^^^
@@ -860,4 +864,4 @@ use raw reads or ``os.read(file.fileno(), maxbytecount)``.
WRITABLE
EXCEPTION
- Constants used in the *mask* arguments.
\ No newline at end of file
+ Constants used in the *mask* arguments.
diff --git a/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst b/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
new file mode 100644
index 0000000000000..617df72faeb37
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-08-03-01-59-48.bpo-41425.KJo6zF.rst
@@ -0,0 +1 @@
+Make tkinter doc example runnable.
_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins