@@ -30,8 +30,8 @@ is maintained at ActiveState.)
3030Tkinter Modules
3131---------------
3232
33- Most of the time, the :mod: `tkinter ` is all you really need, but a number
34- of additional modules are available as well. The Tk interface is located in a
33+ Most of the time, :mod: `tkinter ` is all you really need, but a number of
34+ additional modules are available as well. The Tk interface is located in a
3535binary module named :mod: `_tkinter `. This module contains the low-level
3636interface to Tk, and should never be used directly by application programmers.
3737It is usually a shared library (or DLL), but might in some cases be statically
@@ -112,13 +112,13 @@ orientation on the system.
112112
113113Credits:
114114
115- * Tkinter was written by Steen Lumholt and Guido van Rossum.
116-
117115* Tk was written by John Ousterhout while at Berkeley.
118116
117+ * Tkinter was written by Steen Lumholt and Guido van Rossum.
118+
119119* This Life Preserver was written by Matt Conway at the University of Virginia.
120120
121- * The html rendering, and some liberal editing, was produced from a FrameMaker
121+ * The HTML rendering, and some liberal editing, was produced from a FrameMaker
122122 version by Ken Manheimer.
123123
124124* Fredrik Lundh elaborated and revised the class interface descriptions, to get
@@ -143,10 +143,10 @@ order to use Tkinter, you will have to know a little bit about Tk. This document
143143can't fulfill that role, so the best we can do is point you to the best
144144documentation that exists. Here are some hints:
145145
146- * The authors strongly suggest getting a copy of the Tk man pages. Specifically,
147- the man pages in the ``mann `` directory are most useful. The `` man3 `` man pages
148- describe the C interface to the Tk library and thus are not especially helpful
149- for script writers.
146+ * The authors strongly suggest getting a copy of the Tk man pages.
147+ Specifically, the man pages in the ``manN `` directory are most useful.
148+ The `` man3 `` man pages describe the C interface to the Tk library and thus
149+ are not especially helpful for script writers.
150150
151151* Addison-Wesley publishes a book called Tcl and the Tk Toolkit by John
152152 Ousterhout (ISBN 0-201-63337-X) which is a good introduction to Tcl and Tk for
@@ -159,6 +159,9 @@ documentation that exists. Here are some hints:
159159
160160.. seealso ::
161161
162+ `Tcl/Tk 8.6 man pages <http://www.tcl.tk/man/tcl8.6/ >`_
163+ The Tcl/Tk manual on www.tcl.tk.
164+
162165 `ActiveState Tcl Home Page <http://tcl.activestate.com/ >`_
163166 The Tk/Tcl development is largely taking place at ActiveState.
164167
@@ -183,8 +186,8 @@ A Simple Hello World Program
183186 def createWidgets(self):
184187 self.QUIT = Button(self)
185188 self.QUIT["text"] = "QUIT"
186- self.QUIT["fg"] = "red"
187- self.QUIT["command"] = self.quit
189+ self.QUIT["fg"] = "red"
190+ self.QUIT["command"] = self.quit
188191
189192 self.QUIT.pack({"side": "left"})
190193
@@ -257,7 +260,7 @@ To make a widget in Tk, the command is always of the form::
257260For example::
258261
259262 button .fred -fg red -text "hi there"
260- ^ ^ \_____________________ /
263+ ^ ^ \______________________ /
261264 | | |
262265 class new options
263266 command widget (-opt val -opt val ...)
@@ -301,15 +304,15 @@ constructor, and keyword-args for configure calls or as instance indices, in
301304dictionary style, for established instances. See section
302305:ref: `tkinter-setting-options ` on setting options. ::
303306
304- button .fred -fg red =====> fred = Button(panel, fg = "red")
307+ button .fred -fg red =====> fred = Button(panel, fg= "red")
305308 .fred configure -fg red =====> fred["fg"] = red
306- OR ==> fred.config(fg = "red")
309+ OR ==> fred.config(fg= "red")
307310
308311In Tk, to perform an action on a widget, use the widget name as a command, and
309312follow it with an action name, possibly with arguments (options). In Tkinter,
310313you call methods on the class instance to invoke actions on the widget. The
311- actions (methods) that a given widget can perform are listed in the Tkinter.py
312- module . ::
314+ actions (methods) that a given widget can perform are listed in
315+ :file: ` tkinter/__init__.py ` . ::
313316
314317 .fred invoke =====> fred.invoke()
315318
@@ -320,7 +323,7 @@ various forms of the pack command are implemented as methods. All widgets in
320323methods. See the :mod: `tkinter.tix ` module documentation for additional
321324information on the Form geometry manager. ::
322325
323- pack .fred -side left =====> fred.pack(side = "left")
326+ pack .fred -side left =====> fred.pack(side= "left")
324327
325328
326329How Tk and Tkinter are Related
@@ -332,14 +335,15 @@ Your App Here (Python)
332335 A Python application makes a :mod: `tkinter ` call.
333336
334337tkinter (Python Package)
335- This call (say, for example, creating a button widget), is implemented in the
336- *tkinter * package, which is written in Python. This Python function will parse
337- the commands and the arguments and convert them into a form that makes them look
338- as if they had come from a Tk script instead of a Python script.
338+ This call (say, for example, creating a button widget), is implemented in
339+ the :mod: `tkinter ` package, which is written in Python. This Python
340+ function will parse the commands and the arguments and convert them into a
341+ form that makes them look as if they had come from a Tk script instead of
342+ a Python script.
339343
340- tkinter (C)
344+ _tkinter (C)
341345 These commands and their arguments will be passed to a C function in the
342- * tkinter * - note the lowercase - extension module.
346+ :mod: ` _tkinter ` - note the underscore - extension module.
343347
344348Tk Widgets (C and Tcl)
345349 This C function is able to make calls into other C modules, including the C
@@ -370,7 +374,7 @@ be set in three ways:
370374At object creation time, using keyword arguments
371375 ::
372376
373- fred = Button(self, fg = "red", bg = "blue")
377+ fred = Button(self, fg= "red", bg= "blue")
374378
375379After object creation, treating the option name like a dictionary index
376380 ::
@@ -381,7 +385,7 @@ After object creation, treating the option name like a dictionary index
381385Use the config() method to update multiple attrs subsequent to object creation
382386 ::
383387
384- fred.config(fg = "red", bg = "blue")
388+ fred.config(fg= "red", bg= "blue")
385389
386390For a complete explanation of a given option and its behavior, see the Tk man
387391pages for the widget in question.
@@ -464,8 +468,8 @@ where the widget is to appear within its container, and how it is to behave when
464468the main application window is resized. Here are some examples::
465469
466470 fred.pack() # defaults to side = "top"
467- fred.pack(side = "left")
468- fred.pack(expand = 1)
471+ fred.pack(side= "left")
472+ fred.pack(expand= 1)
469473
470474
471475Packer Options
@@ -506,7 +510,7 @@ Unfortunately, in the current implementation of :mod:`tkinter` it is not
506510possible to hand over an arbitrary Python variable to a widget through a
507511``variable `` or ``textvariable `` option. The only kinds of variables for which
508512this works are variables that are subclassed from a class called Variable,
509- defined in the :mod: `tkinter `.
513+ defined in :mod: `tkinter `.
510514
511515There are many useful subclasses of Variable already defined:
512516:class: `StringVar `, :class: `IntVar `, :class: `DoubleVar `, and
@@ -606,7 +610,7 @@ callback
606610 This is any Python function that takes no arguments. For example::
607611
608612 def print_it():
609- print("hi there")
613+ print("hi there")
610614 fred["command"] = print_it
611615
612616color
@@ -702,24 +706,32 @@ Notice how the widget field of the event is being accessed in the
702706:meth: `turnRed ` callback. This field contains the widget that caught the X
703707event. The following table lists the other event fields you can access, and how
704708they are denoted in Tk, which can be useful when referring to the Tk man pages.
705- ::
706709
707- Tk Tkinter Event Field Tk Tkinter Event Field
708- -- ------------------- -- -------------------
709- %f focus %A char
710- %h height %E send_event
711- %k keycode %K keysym
712- %s state %N keysym_num
713- %t time %T type
714- %w width %W widget
715- %x x %X x_root
716- %y y %Y y_root
710+ +----+---------------------+----+---------------------+
711+ | Tk | Tkinter Event Field | Tk | Tkinter Event Field |
712+ +====+=====================+====+=====================+
713+ | %f | focus | %A | char |
714+ +----+---------------------+----+---------------------+
715+ | %h | height | %E | send_event |
716+ +----+---------------------+----+---------------------+
717+ | %k | keycode | %K | keysym |
718+ +----+---------------------+----+---------------------+
719+ | %s | state | %N | keysym_num |
720+ +----+---------------------+----+---------------------+
721+ | %t | time | %T | type |
722+ +----+---------------------+----+---------------------+
723+ | %w | width | %W | widget |
724+ +----+---------------------+----+---------------------+
725+ | %x | x | %X | x_root |
726+ +----+---------------------+----+---------------------+
727+ | %y | y | %Y | y_root |
728+ +----+---------------------+----+---------------------+
717729
718730
719731The index Parameter
720732^^^^^^^^^^^^^^^^^^^
721733
722- A number of widgets require"index" parameters to be passed. These are used to
734+ A number of widgets require "index" parameters to be passed. These are used to
723735point at a specific place in a Text widget, or to particular characters in an
724736Entry widget, or to particular menu items in a Menu widget.
725737
@@ -755,7 +767,7 @@ Menu indexes (menu.invoke(), menu.entryconfig(), etc.)
755767 * an integer which refers to the numeric position of the entry in the widget,
756768 counted from the top, starting with 0;
757769
758- * the string ``' active' ``, which refers to the menu position that is currently
770+ * the string ``" active" ``, which refers to the menu position that is currently
759771 under the cursor;
760772
761773 * the string ``"last" `` which refers to the last menu item;
0 commit comments