summaryrefslogtreecommitdiff
path: root/Doc/library/tkinter.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/tkinter.rst')
-rw-r--r--Doc/library/tkinter.rst73
1 files changed, 37 insertions, 36 deletions
diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
index f6e095a5c0..eeb1f8096e 100644
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -37,9 +37,6 @@ this should open a window demonstrating a simple Tk interface.
`Modern Tkinter for Busy Python Developers <http://www.amazon.com/Modern-Tkinter-Python-Developers-ebook/dp/B0071QDNLO/>`_
Book by Mark Rozerman about building attractive and modern graphical user interfaces with Python and Tkinter.
- `An Introduction to Tkinter <http://www.pythonware.com/library/an-introduction-to-tkinter.htm>`_
- Fredrik Lundh's on-line reference material.
-
`Python and Tkinter Programming <http://www.amazon.com/exec/obidos/ASIN/1884777813>`_
The book by John Grayson (ISBN 1-884777-81-3).
@@ -183,7 +180,7 @@ documentation that exists. Here are some hints:
The Tk/Tcl development is largely taking place at ActiveState.
`Tcl and the Tk Toolkit <http://www.amazon.com/exec/obidos/ASIN/020163337X>`_
- The book by John Ousterhout, the inventor of Tcl .
+ The book by John Ousterhout, the inventor of Tcl.
`Practical Programming in Tcl and Tk <http://www.amazon.com/exec/obidos/ASIN/0130220280>`_
Brent Welch's encyclopedic book.
@@ -194,35 +191,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
+ import tkinter as tk
- self.QUIT.pack({"side": "left"})
+ class Application(tk.Frame):
+ def __init__(self, master=None):
+ tk.Frame.__init__(self, master)
+ self.pack()
+ self.createWidgets()
- self.hi_there = Button(self)
- self.hi_there["text"] = "Hello",
- self.hi_there["command"] = self.say_hi
+ 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.hi_there.pack({"side": "left"})
+ self.QUIT = tk.Button(self, text="QUIT", fg="red",
+ command=root.destroy)
+ self.QUIT.pack(side="bottom")
- def __init__(self, master=None):
- Frame.__init__(self, master)
- self.pack()
- self.createWidgets()
+ def say_hi(self):
+ print("hi there, everyone!")
- root = Tk()
- app = Application(master=root)
- app.mainloop()
- root.destroy()
+ root = tk.Tk()
+ app = Application(master=root)
+ app.mainloop()
A (Very) Quick Look at Tcl/Tk
@@ -448,7 +440,7 @@ back will contain the name of the synonym and the "real" option (such as
Example::
>>> print(fred.config())
- {'relief' : ('relief', 'relief', 'Relief', 'raised', 'groove')}
+ {'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}
Of course, the dictionary printed will include all the options available and
their values. This is meant only as an example.
@@ -621,7 +613,7 @@ bitmap
preceded with an ``@``, as in ``"@/usr/contrib/bitmap/gumby.bit"``.
boolean
- You can pass integers 0 or 1 or the strings ``"yes"`` or ``"no"`` .
+ You can pass integers 0 or 1 or the strings ``"yes"`` or ``"no"``.
callback
This is any Python function that takes no arguments. For example::
@@ -755,22 +747,32 @@ Entry widget indexes (index, view index, etc.)
displayed. You can use these :mod:`tkinter` functions to access these special
points in text widgets:
- AtEnd()
+.. function:: AtEnd()
refers to the last position in the text
- AtInsert()
+ .. deprecated:: 3.3
+
+.. function:: AtInsert()
refers to the point where the text cursor is
- AtSelFirst()
+ .. deprecated:: 3.3
+
+.. function:: AtSelFirst()
indicates the beginning point of the selected text
- AtSelLast()
+ .. deprecated:: 3.3
+
+.. function:: AtSelLast()
denotes the last point of the selected text and finally
- At(x[, y])
+ .. deprecated:: 3.3
+
+.. function:: At(x[, y])
refers to the character at pixel location *x*, *y* (with *y* not used in the
case of a text entry widget, which contains a single line of text).
+ .. deprecated:: 3.3
+
Text widget indexes
The index notation for Text widgets is very rich and is best described in the Tk
man pages.
@@ -818,4 +820,3 @@ some widget (e.g. labels, buttons, menus). In these cases, Tk will not keep a
reference to the image. When the last Python reference to the image object is
deleted, the image data is deleted as well, and Tk will display an empty box
wherever the image was used.
-