blob: edc971a66b523844a5674d1cf989540fb78a3c2c [file] [log] [blame]
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001\chapter{Graphical User Interface Modules \label{gui}}
2
3\index{GUI}
4\index{Graphical User Interface}
5\index{Tkinter}
6\index{Tk}
7
8Tk/Tcl has long been an integral part of Python. It provides a robust
9and platform independent windowing toolkit, that is available to
10Python programmers using the \refmodule{Tkinter} module, and its
11extension, the \refmodule{Tix} module.
12
13\refmodule{Tkinter} is a thin object--oriented layer on top of
14Tcl/Tk. To use \refmodule{Tkinter}, you don't need to write Tcl code,
15but you will need to consult the Tk documentation, and occasionally
16the Tcl documentation. \refmodule{Tkinter} is a set of wrappers that
17implement the Tk widgets as Python classes. In addition, the internal
18module \module{\_tkinter} provides a threadsafe mechanism which allows
19Python and Tcl to interact.
20
21\refmodule{Tkinter} is not the only GUI for Python, but is however the
22most commonly used one; see section~\ref{other-gui-modules},
23``Other User Interface Modules and Packages'' for more information on
24other GUI toolkits for Python.
25
26% Other sections I have in mind are
27% Tkinter internals
28% Freezing Tkinter applications
29
30\localmoduletable
31
32
Fred Drakec66ff202001-11-16 01:05:27 +000033\section{\module{Tkinter} ---
34 Python interface to Tcl/Tk}
Fred Drake7cf4e5b2001-11-15 17:22:04 +000035
36\declaremodule{standard}{Tkinter}
37\modulesynopsis{Interface to Tcl/Tk for graphical user interfaces}
38\moduleauthor{Guido van Rossum}{guido@Python.org}
39
40The \module{Tkinter} module (``Tk interface'') is the standard Python
41interface to the Tk GUI toolkit, now maintained at ActiveState. Both
42Tk and \module{Tkinter} are available on most Unix platforms, as well
43as on Windows and Macintosh systems.
44
45\begin{seealso}
46\seetitle[http://www.python.org/topics/tkinter/]
47 {Python Tkinter Resources}
48 {The Python Tkinter Topic Guide provides a great
49 deal of information on using Tk from Python and links to
50 other sources of information on Tk.}
51
52\seetitle[http://www.pythonware.com/library/an-introduction-to-tkinter.htm]
53 {An Introduction to Tkinter}
54 {Fredrik Lundh's on-line reference material.}
55
56\seetitle[http://www.nmt.edu/tcc/help/pubs/lang.html]
57 {Tkinter reference: a GUI for Python}
58 {On-line reference material.}
59
60\seetitle[http://jtkinter.sourceforge.net]
61 {Tkinter for JPython}
62 {The Jython interface to Tkinter.}
63
64\seetitle[http://www.amazon.com/exec/obidos/ASIN/1884777813]
65 {Python and Tkinter Programming}
66 {The book by John Grayson (ISBN 1-884777-81-3).}
67\end{seealso}
68
69
70\subsection{Tkinter Modules}
71
72\refmodule{Tkinter} consists of a number of modules. The Tk interface
73is located in a binary module named \module{_tkinter}. This module
74contains the low-level interface to Tk, and should never be used
75directly by application programmers. It is usually a shared library
76(or DLL), but might in some cases be statically linked with the Python
77interpreter.
78
79In addition to the Tk interface module, \refmodule{Tkinter} includes a
80number of Python modules. The two most important modules are the
81\refmodule{Tkinter} module itself, and a module called
82\module{Tkconstants}. The former automatically imports the latter, so
83to use Tkinter, all you need to do is to import one module:
84
85\begin{verbatim}
86import Tkinter
87\end{verbatim}
88
89Or, more often:
90
91\begin{verbatim}
92from Tkinter import *
93\end{verbatim}
94
95\begin{classdesc}{Tk}{screenName=None, baseName=None, className='Tk'}
96The \class{Tk} class is instantiated without arguments.
97This creates a toplevel widget of Tk which usually is the main window
98of an appliation. Each instance has its own associated Tcl interpreter.
99% FIXME: The following keyword arguments are currently recognized:
100\end{classdesc}
101
102Other modules that provide Tk support include:
103
104\begin{description}
105% \declaremodule{standard}{Tkconstants}
106% \modulesynopsis{Constants used by Tkinter}
107% FIXME
108
Fred Drakec66ff202001-11-16 01:05:27 +0000109\item[\module{tkColorChooser}]
110Dialog to let the user choose a color.
111
112\item[\module{tkCommonDialog}]
113
114\item[\module{tkFileDialog}]
115Common dialogs to allow the user to specify a file to open or save.
116
117\item[\module{tkFont}]
118Utilities to help work with fonts.
119
120\item[\module{tkMessageBox}]
121Access to standard Tk dialog boxes.
122
123\item[\module{tkSimpleDialog}]
124Basic dialogs and convenience functions.
125
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000126\item[\module{Tkdnd}]
127Drag-and-drop support for \refmodule{Tkinter}.
128This is experimental and should become deprecated when it is replaced
129with the Tk DND.
130
131\item[\refmodule{turtle}]
132Turtle graphics in a Tk window.
133
134\end{description}
135
136\subsection{Tkinter Life Preserver}
Fred Drakec66ff202001-11-16 01:05:27 +0000137\sectionauthor{Matt Conway}{}
138% Converted to LaTeX by Mike Clarkson.
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000139
140This section is not designed to be an exhaustive tutorial on either
141Tk or Tkinter. Rather, it is intended as a stop gap, providing some
142introductory orientation on the system.
143
144Credits:
145\begin{itemize}
146\item Tkinter was written by Steen Lumholt and Guido van Rossum.
147\item Tk was written by John Ousterhout while at Berkeley.
148\item This Life Preserver was written by Matt Conway at
149the University of Virginia.
150\item The html rendering, and some liberal editing, was
151produced from a FrameMaker version by Ken Manheimer.
152\item Fredrik Lundh elaborated and revised the class interface descriptions,
153to get them current with Tk 4.2.
154\item Mike Clarkson converted the documentation to \LaTeX, and compiled the
155User Interface chapter of the reference manual.
156\end{itemize}
157
158
159\subsubsection{How To Use This Section}
160
161This section is designed in two parts: the first half (roughly) covers
162background material, while the second half can be taken to the
163keyboard as a handy reference.
164
165When trying to answer questions of the form ``how do I do blah'', it
166is often best to find out how to do``blah'' in straight Tk, and then
167convert this back into the corresponding \refmodule{Tkinter} call.
168Python programmers can often guess at the correct Python command by
169looking at the Tk documentation. This means that in order to use
170Tkinter, you will have to know a little bit about Tk. This document
171can't fulfill that role, so the best we can do is point you to the
172best documentation that exists. Here are some hints:
173
174\begin{itemize}
175\item The authors strongly suggest getting a copy of the Tk man
176pages. Specifically, the man pages in the \code{mann} directory are most
177useful. The \code{man3} man pages describe the C interface to the Tk
178library and thus are not especially helpful for script writers.
179
180\item Addison-Wesley publishes a book called \citetitle{Tcl and the
181Tk Toolkit} by John Ousterhout (ISBN 0-201-63337-X) which is a good
182introduction to Tcl and Tk for the novice. The book is not
183exhaustive, and for many details it defers to the man pages.
184
185\item \file{Tkinter.py} is a last resort for most, but can be a good
186place to go when nothing else makes sense.
187\end{itemize}
188
189\begin{seealso}
190\seetitle[http://tcl.activestate.com/]
191 {ActiveState Tcl Home Page}
192 {The Tk/Tcl development is largely taking place at
193 ActiveState.}
194\seetitle[http://www.amazon.com/exec/obidos/ASIN/020163337X]
195 {Tcl and the Tk Toolkit}
196 {The book by John Ousterhout, the inventor of Tcl .}
197\seetitle[http://www.amazon.com/exec/obidos/ASIN/0130220280]
198 {Practical Programming in Tcl and Tk}
199 {Brent Welch's encyclopedic book.}
200\end{seealso}
201
202
203\subsubsection{A Simple Hello World Program} % HelloWorld.html
204
205%begin{latexonly}
206%\begin{figure}[hbtp]
207%\centerline{\epsfig{file=HelloWorld.gif,width=.9\textwidth}}
208%\vspace{.5cm}
209%\caption{HelloWorld gadget image}
210%\end{figure}
211%See also the hello-world \ulink{notes}{classes/HelloWorld-notes.html} and
212%\ulink{summary}{classes/HelloWorld-summary.html}.
213%end{latexonly}
214
215
216\begin{verbatim}
217from Tkinter import * 1
218 2
219class Application(Frame): 3
220 def say_hi(self): 4
221 print "hi there, everyone!" 5
222 6
223 def createWidgets(self): 7
224 self.QUIT = Button(self) 8
225 self.QUIT["text"] = "QUIT" 9
226 self.QUIT["fg"] = "red" 10
227 self.QUIT["command"] = self.quit 11
228 12
229 self.QUIT.pack({"side": "left"}) 13
230 14
231 self.hi_there = Button(self) 15
232 self.hi_there["text"] = "Hello", 16
233 self.hi_there["command"] = self.say_hi 17
234 18
235 self.hi_there.pack({"side": "left"}) 19
236 20
237 21
238 def __init__(self, master=None): 22
239 Frame.__init__(self, master) 23
240 self.pack() 24
241 self.createWidgets() 25
242 26
243app = Application() 27
244app.mainloop() 28
245\end{verbatim}
246
247\ifhtml
248\subsection{An Overview of The Tkinter Classes} % TkClassHier.html
249
250%begin{latexonly}
251%\begin{figure}[hbtp]
252%\centerline{\epsfig{file=TkClassHier.gif,width=.9\textwidth}}
253%\caption{Class Hierarchy Image}
254%\end{figure}
255%end{latexonly}
256
257The class hierarchy looks complicated, but in actual practice,
258application programmers almost always refer to the classes at the very
259bottom of the hierarchy.
260
261Here are links to the interfaces for each of the concrete widgets:
262
263\begin{itemize}
264\item \citetitle[classes/ClassButton.html]{Button}
265\item \citetitle[classes/ClassCanvas.html]{Canvas}
266\item \citetitle[classes/ClassCheckbutton.html]{Checkbutton}
267\item \citetitle[classes/ClassEntry.html]{Entry}
268\item \citetitle[classes/ClassFrame.html]{Frame}
269\item \citetitle[classes/ClassLabel.html]{Label}
270\item \citetitle[classes/ClassListbox.html]{Listbox}
271\item \citetitle[classes/ClassMenu.html]{Menu}
272\item \citetitle[classes/ClassMenubutton.html]{Menubutton}
273\item \citetitle[classes/ClassMessage.html]{Message}
274\item \citetitle[classes/ClassMisc.html]{*Misc}
275\item \citetitle[classes/ClassPacker.html]{*Pack}
276\item \citetitle[classes/ClassPlacer.html]{*Place}
277\item \citetitle[classes/ClassRadiobutton.html]{Radiobutton}
278\item \citetitle[classes/ClassScale.html]{Scale}
279\item \citetitle[classes/ClassScrollbar.html]{Scrollbar}
280\item \citetitle[classes/ClassText.html]{Text}
281\item \citetitle[classes/ClassTk.html]{**Tk}
282\item \citetitle[classes/ClassToplevel.html]{Toplevel}
283\item \citetitle[classes/ClassWidget.html]{***Widget}
284\item \citetitle[classes/ClassWm.html]{*Wm}
285\end{itemize}
286
287
288Notes:
289\begin{itemize}
290\item These classes are provided for the purposes of
291organizing certain functions under one namespace. They aren't meant to
292be instantiated independently.
293\item The Tk class is meant to be instantiated only once in
294an application. Application programmers need not instantiate one
295explicitly, the system creates one whenever any of the other classes
296are instantiated.
297\item The Widget class is not meant to be instantiated, it
Fred Drakec66ff202001-11-16 01:05:27 +0000298is meant only for subclassing to make ``real'' widgets. (in \Cpp, this
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000299is called an `abstract class')
300\end{itemize}
301\fi
302
303
304\subsection{A (Very) Quick Look at Tcl/Tk} % BriefTclTk.html
305
306To make use of this reference material, there will be times when you
307will need to know how to read short passages of Tk and how to identify
308the various parts of a Tk command.
309(See \ref{tkinter-basic-mapping} for the
310\refmodule{Tkinter} equivalents of what's below.)
311
312Tk scripts are Tcl programs. Like all Tcl programs, Tk scripts are
313just lists of tokens separated by spaces. A Tk widget is just its
314\emph{class}, the \emph{options} that help configure it, and the
315\emph{actions} that make it do useful things.
316
317To make a widget in Tk, the command is always of the form:
318
319\begin{verbatim}
320 classCommand newPathname options
321\end{verbatim}
322
323\begin{description}
324\item[\var{classCommand}]
325denotes which kind of widget to make (a button, a label, a menu...)
326
327\item[\var{newPathname}]
328is the new name for this widget. All names in Tk must be unique. To
329help enforce this, widgets in Tk are named with \emph{pathnames}, just
330like files in a file system. The top level widget, the \emph{root},
331is called \code{.} (period) and children are delimited by more
332periods. For example, \code{.myApp.controlPanel.okButton} might be
333the name of a widget.
334
335\item[\var{options} ]
336configure the widget's appearance and in some cases, its
337behavior. The options come in the form of a list of flags and values.
338Flags are proceeded by a `-', like unix shell command flags, and
339values are put in quotes if they are more than one word.
340\end{description}
341
342For example:
343
344\begin{verbatim}
345 button .fred -fg red -text "hi there"
346 ^ ^ \_____________________/
347 | | |
348 class new options
349 command widget (-opt val -opt val ...)
350\end{verbatim}
351
352Once created, the pathname to the widget becomes a new command. This
353new \var{widget command} is the programmer's handle for getting the new
354widget to perform some \var{action}. In C, you'd express this as
Fred Drakec66ff202001-11-16 01:05:27 +0000355someAction(fred, someOptions), in \Cpp, you would express this as
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000356fred.someAction(someOptions), and in Tk, you say:
357
358\begin{verbatim}
359 .fred someAction someOptions
360\end{verbatim}
361
362Note that the object name, \code{.fred}, starts with a dot.
363
364As you'd expect, the legal values for \var{someAction} will depend on
365the widget's class: \code{.fred disable} works if fred is a
366button (fred gets greyed out), but does not work if fred is a label
367(disabling of labels is not supported in Tk).
368
369The legal values of \var{someOptions} is action dependent. Some
370actions, like \code{disable}, require no arguments, others, like
371a text-entry box's \code{delete} command, would need arguments
372to specify what range of text to delete.
373
374
375\subsection{Mapping Basic Tk into Tkinter
376 \label{tkinter-basic-mapping}}
377
378Class commands in Tk correspond to class constructors in Tkinter.
379
380\begin{verbatim}
381 button .fred =====> fred = Button()
382\end{verbatim}
383
384The master of an object is implicit in the new name given to it at
385creation time. In Tkinter, masters are specified explicitly.
386
387\begin{verbatim}
388 button .panel.fred =====> fred = Button(panel)
389\end{verbatim}
390
391The configuration options in Tk are given in lists of hyphened tags
392followed by values. In Tkinter, options are specified as
393keyword-arguments in the instance constructor, and keyword-args for
394configure calls or as instance indices, in dictionary style, for
395established instances. See \ref{tkinter-setting-options}
396on setting options.
397
398\begin{verbatim}
399 button .fred -fg red =====> fred = Button(panel, fg = "red")
400 .fred configure -fg red =====> fred["fg"] = red
401 OR ==> fred.config(fg = "red")
402\end{verbatim}
403
404In Tk, to perform an action on a widget, use the widget name as a
405command, and follow it with an action name, possibly with arguments
406(options). In Tkinter, you call methods on the class instance to
407invoke actions on the widget. The actions (methods) that a given
408widget can perform are listed in the Tkinter.py module.
409
410\begin{verbatim}
411 .fred invoke =====> fred.invoke()
412\end{verbatim}
413
414To give a widget to the packer (geometry manager), you call pack with
415optional arguments. In Tkinter, the Pack class holds all this
416functionality, and the various forms of the pack command are
417implemented as methods. All widgets in \refmodule{Tkinter} are
418subclassed from the Packer, and so inherit all the packing
419methods. See the \refmodule{Tix} module documentation for additional
420information on the Form geometry manager.
421
422\begin{verbatim}
423 pack .fred -side left =====> fred.pack(side = "left")
424\end{verbatim}
425
426
427\subsection{How Tk and Tkinter are Related} % Relationship.html
428
429From the top down:
430\begin{description}
431\item[\b{Your App Here (Python)}]
432A Python application makes a \refmodule{Tkinter} call.
433
434\item[\b{Tkinter (Python Module)}]
435This call (say, for example, creating a button widget), is
436implemented in the \emph{Tkinter} module, which is written in
437Python. This Python function will parse the commands and the
438arguments and convert them into a form that makes them look as if they
439had come from a Tk script instead of a Python script.
440
441\item[\b{tkinter (C)}]
442These commands and their arguments will be passed to a C function
443in the \emph{tkinter} - note the lowercase - extension module.
444
445\item[\b{Tk Widgets} (C and Tcl)]
446This C function is able to make calls into other C modules,
447including the C functions that make up the Tk library. Tk is
448implemented in C and some Tcl. The Tcl part of the Tk widgets is used
449to bind certain default behaviors to widgets, and is executed once at
450the point where the Python \refmodule{Tkinter} module is
451imported. (The user never sees this stage).
452
453\item[\b{Tk (C)}]
454The Tk part of the Tk Widgets implement the final mapping to ...
455
456\item[\b{Xlib (C)}]
457the Xlib library to draw graphics on the screen.
458\end{description}
459
460
461\subsection{Handy Reference}
462
463\subsubsection{Setting Options
464 \label{tkinter-setting-options}}
465
466Options control things like the color and border width of a widget.
467Options can be set in three ways:
468
469\begin{description}
470\item[At object creation time, using keyword arguments]:
471\begin{verbatim}
472fred = Button(self, fg = "red", bg = "blue")
473\end{verbatim}
474\item[After object creation, treating the option name like a dictionary index]:
475\begin{verbatim}
476fred["fg"] = "red"
477fred["bg"] = "blue"
478\end{verbatim}
479\item[Use the config() method to update multiple attrs subesequent to
480object creation]:
481\begin{verbatim}
482fred.config(fg = "red", bg = "blue")
483\end{verbatim}
484\end{description}
485
486For a complete explanation of a given option and its behavior, see the
487Tk man pages for the widget in question.
488
489Note that the man pages list "STANDARD OPTIONS" and "WIDGET SPECIFIC
490OPTIONS" for each widget. The former is a list of options that are
491common to many widgets, the latter are the options that are
492ideosyncratic to that particular widget. The Standard Options are
493documented on the \manpage{options}{3} man page.
494
495No distinction between standard and widget-specific options is made in
496this document. Some options don't apply to some kinds of widgets.
497Whether a given widget responds to a particular option depends on the
498class of the widget; buttons have a \code{command} option, labels do not.
499
500The options supported by a given widget are listed in that widget's
501man page, or can be queried at runtime by calling the
502\kbd{config()} method with arguments, or by calling the keys()
503method on that widget. The return value of these calls is a dictionary
504whose key is the name of the option (e.g. \kbd{relief}) and whose
505values are 5 tuples.
506
507(Some options, like \kbd{bg} are synonyms for common options with
508hard-to-type names (\kbd{bg} is shorthand for "background").
509Passing the \kbd{config()} method the name of a
510shorthand option will return a 2-tuple, not 5-tuple. The 2-tuple
511passed back will contain the name of the synonym ``real''
512option. (\kbd{bg}, \kbd{background}))
513
514\begin{tableiii}{c|l|l}{textrm}{Index}{Meaning}{Example}
515 \lineiii{0}{option name} {\code{'relief'}}
516 \lineiii{1}{option name for database lookup} {\code{'relief'}}
517 \lineiii{2}{option class for database lookup} {\code{'Relief'}}
518 \lineiii{3}{default value} {\code{'raised'}}
519 \lineiii{4}{current value} {\code{'groove'}}
520\end{tableiii}
521
522
523Example:
524
525\begin{verbatim}
526>>> print fred.config()
527{'relief' : ('relief', 'relief', 'Relief', 'raised', 'groove')}
528\end{verbatim}
529
530Of course, the dictionary printed will include all the options
531available and their values. This is meant only as an example.
532
533
534\subsubsection{The Packer} % Packer.html
535\index{packing (widgets)}
536
537The packer is one of Tk's geometry-management mechanisms. See also
538\citetitle[classes/ClassPacker.html]{the Packer class interface}.
539
540Geometry managers are used to specify the relative positioning of the
541positioning of widgets within their container - their mutual
542\emph{master}. In contrast to the more cumbersome \emph{placer}
543(which is used less commonly, and we do not cover here), the packer
544takes qualitative relationship specification - \emph{above}, \emph{to
545the left of}, \emph{filling}, etc - and works everything out to
546determine the exact placement coordinates for you.
547
548The size of any \emph{master} widget is determined by the size of
549the "slave widgets" inside. The packer is used to control where slave
550widgets appear inside the master into which they are packed. You can
551pack widgets into frames, and frames into other frames, in order to
552achieve the kind of layout you desire. Additionally, the arrangement
553is dynamically adjusted to accomodate incremental changes to the
554configuration, once it is packed.
555
556Note that widgets do not appear until they have had their geometry
557specified with a geometry manager. It's a common early mistake to
558leave out the geometry specification, and then be surprised when the
559widget is created but nothing appears. A widget will appear only
560after it has had, for example, the packer's \method{pack()} method
561applied to it.
562
563The pack() method can be called with keyword-option/value pairs that
564control where the widget is to appear within its container, and how it
565is to behave when the main application window is resized. Here are
566some examples:
567
568\begin{verbatim}
569 fred.pack() # defaults to side = "top"
570 fred.pack(side = "left")
571 fred.pack(expand = 1)
572\end{verbatim}
573
574
575\subsubsection{Packer Options}
576
577For more extensive information on the packer and the options that it
578can take, see the man pages and page 183 of John Ousterhout's book.
579
580\begin{description}
581\item[\b{anchor }]
582Anchor type. Denotes where the packer is to place each slave in its
583parcel.
584
585\item[\b{expand}]
586Boolean, \code{0} or \code{1}.
587
588\item[\b{fill}]
589Legal values: \code{'x'}, \code{'y'}, \code{'both'}, \code{'none'}.
590
591\item[\b{ipadx} and \b{ipady}]
592A distance - designating internal padding on each side of the slave
593widget.
594
595\item[\b{padx} and \b{pady}]
596A distance - designating external padding on each side of the slave
597widget.
598
599\item[\b{side}]
600Legal values are: \code{'left'}, \code{'right'}, \code{'top'},
601\code{'bottom'}.
602\end{description}
603
604
605\subsubsection{Coupling Widget Variables} % VarCouplings.html
606
607The current-value setting of some widgets (like text entry widgets)
608can be connected directly to application variables by using special
609options. These options are \code{variable}, \code{textvariable},
610\code{onvalue}, \code{offvalue}, and \code{value}. This
611connection works both ways: if the variable changes for any reason,
612the widget it's connected to will be updated to reflect the new value.
613
614Unfortunately, in the current implementation of \refmodule{Tkinter} it is
615not possible to hand over an arbitrary Python variable to a widget
616through a \code{variable} or \code{textvariable} option. The only
617kinds of variables for which this works are variables that are
618subclassed from a class called Variable, defined in the
619\refmodule{Tkinter} module.
620
621There are many useful subclasses of Variable already defined:
622\class{StringVar}, \class{IntVar}, \class{DoubleVar}, and
623\class{BooleanVar}. To read the current value of such a variable,
624call the \method{get()} method on
625it, and to change its value you call the \method{set()} method. If
626you follow this protocol, the widget will always track the value of
627the variable, with no further intervention on your part.
628
629For example:
630\begin{verbatim}
631class App(Frame):
632 def __init__(self, master=None):
633 Frame.__init__(self, master)
634 self.pack()
635
636 self.entrythingy = Entry()
637 self.entrythingy.pack()
638
639 self.button.pack()
640 # here is the application variable
641 self.contents = StringVar()
642 # set it to some value
643 self.contents.set("this is a variable")
644 # tell the entry widget to watch this variable
645 self.entrythingy["textvariable"] = self.contents
646
647 # and here we get a callback when the user hits return.
648 # we will have the program print out the value of the
649 # application variable when the user hits return
650 self.entrythingy.bind('<Key-Return>',
651 self.print_contents)
652
653 def print_contents(self, event):
654 print "hi. contents of entry is now ---->", \
655 self.contents.get()
656\end{verbatim}
657
658
659\subsubsection{The Window Manager} % WindowMgr.html
660\index{window manager (widgets)}
661
662In Tk, there is a utility command, \code{wm}, for interacting with the
663window manager. Options to the \code{wm} command allow you to control
664things like titles, placement, icon bitmaps, and the like. In
665\refmodule{Tkinter}, these commands have been implemented as methods
666on the \class{Wm} class. Toplevel widgets are subclassed from the
667\class{Wm} class, and so can call the \class{Wm} methods directly.
668
669%See also \citetitle[classes/ClassWm.html]{the Wm class interface}.
670
671To get at the toplevel window that contains a given widget, you can
672often just refer to the widget's master. Of course if the widget has
673been packed inside of a frame, the master won't represent a toplevel
674window. To get at the toplevel window that contains an arbitrary
675widget, you can call the \method{_root()} method. This
676method begins with an underscore to denote the fact that this function
677is part of the implementation, and not an interface to Tk functionality.
678
679Here are some examples of typical usage:
680
681\begin{verbatim}
682import Tkinter
683class App(Frame):
684 def __init__(self, master=None):
685 Frame.__init__(self, master)
686 self.pack()
687
688
689# create the application
690myapp = App()
691
692#
693# here are method calls to the window manager class
694#
695myapp.master.title("My Do-Nothing Application")
696myapp.master.maxsize(1000, 400)
697
698# start the program
699myapp.mainloop()
700\end{verbatim}
701
702
703\subsubsection{Tk Option Data Types} % OptionTypes.html
704
705\index{Tk Option Data Types}
706
707\begin{description}
708\item[anchor]
709Legal values are points of the compass: \code{"n"},
710\code{"ne"}, \code{"e"}, \code{"se"}, \code{"s"},
711\code{"sw"}, \code{"w"}, \code{"nw"}, and also
712\code{"center"}.
713
714\item[bitmap]
715There are eight built-in, named bitmaps: \code{'error'}, \code{'gray25'},
716\code{'gray50'}, \code{'hourglass'}, \code{'info'}, \code{'questhead'},
717\code{'question'}, \code{'warning'}. To specify an X bitmap
718filename, give the full path to the file, preceded with an \code{@},
719as in \code{"@/usr/contrib/bitmap/gumby.bit"}.
720
721\item[boolean]
722You can pass integers 0 or 1 or the stings \code{"yes"} or \code{"no"} .
723
724\item[callback]
725This is any Python function that takes no arguments. For example:
726\begin{verbatim}
727 def print_it():
728 print "hi there"
729 fred["command"] = print_it
730\end{verbatim}
731
732\item[color]
733Colors can be given as the names of X colors in the rgb.txt file,
734or as strings representing RGB values in 4 bit: \code{"\#RGB"}, 8
735bit: \code{"\#RRGGBB"}, 12 bit" \code{"\#RRRGGGBBB"}, or 16 bit
736\code{"\#RRRRGGGGBBBB"} ranges, where R,G,B here represent any
737legal hex digit. See page 160 of Ousterhout's book for details.
738
739\item[cursor]
740The standard X cursor names from \file{cursorfont.h} can be used,
741without the \code{XC_} prefix. For example to get a hand cursor
742(\constant{XC_hand2}), use the string \code{"hand2"}. You can also
743specify a bitmap and mask file of your own. See page 179 of
744Ousterhout's book.
745
746\item[distance]
747Screen distances can be specified in either pixels or absolute
748distances. Pixels are given as numbers and absolute distances as
749strings, with the trailing character denoting units: \code{c}
750for centimeters, \code{i} for inches, \code{m} for millimeters,
751\code{p} for printer's points. For example, 3.5 inches is expressed
752as \code{"3.5i"}.
753
754\item[font]
755Tk uses a list font name format, such as \code{\{courier 10 bold\}}.
756Font sizes with positive numbers are measured in points;
757sizes with negative numbers are measured in pixels.
758
759\item[geometry]
760This is a string of the form \samp{\var{width}x\var{height}}, where
761width and height are measured in pixels for most widgets (in
762characters for widgets displaying text). For example:
763\code{fred["geometry"] = "200x100"}.
764
765\item[justify]
766Legal values are the strings: \code{"left"},
767\code{"center"}, \code{"right"}, and \code{"fill"}.
768
769\item[region]
770This is a string with four space-delimited elements, each of
771which is a legal distance (see above). For example: \code{"2 3 4
7725"} and \code{"3i 2i 4.5i 2i"} and \code{"3c 2c 4c 10.43c"}
773are all legal regions.
774
775\item[relief]
776Determines what the border style of a widget will be. Legal
777values are: \code{"raised"}, \code{"sunken"},
778\code{"flat"}, \code{"groove"}, and \code{"ridge"}.
779
780\item[scrollcommand]
781This is almost always the \method{set()} method of some scrollbar
782widget, but can be any widget method that takes a single argument.
783Refer to the file \file{Demo/tkinter/matt/canvas-with-scrollbars.py}
784in the Python source distribution for an example.
785
786\item[wrap:]
787Must be one of: \code{"none"}, \code{"char"}, or \code{"word"}.
788\end{description}
789
790
791\subsubsection{Bindings and Events} % Bindings.html
792
793\index{bind (widgets)}
794\index{events (widgets)}
795
796The bind method from the widget command allows you to watch for
797certain events and to have a callback function trigger when that event
798type occurs. The form of the bind method is:
799
800\begin{verbatim}
801 def bind(self, sequence, func, add=''):
802\end{verbatim}
803where:
804
805\begin{description}
806\item[sequence]
807is a string that denotes the target kind of event. (See the bind
808man page and page 201 of John Ousterhout's book for details).
809
810\item[func]
811is a Python function, taking one argument, to be invoked when the
812event occurs. An Event instance will be passed as the argument.
813(Functions deployed this way are commonly known as \var{callbacks}.)
814
815\item[add]
816is optional, either \samp{} or \samp{+}. Passing an empty string
817denotes that this binding is to replace any other bindings that this
818event is associated with. Preceeding with a \samp{+} means that this
819function is to be added to the list of functions bound to this event type.
820\end{description}
821
822For example:
823\begin{verbatim}
824 def turnRed(self, event):
825 event.widget["activeforeground"] = "red"
826
827 self.button.bind("<Enter>", self.turnRed)
828\end{verbatim}
829
830Notice how the widget field of the event is being accesed in the
831\method{turnRed()} callback. This field contains the widget that
832caught the X event. The following table lists the other event fields
833you can access, and how they are denoted in Tk, which can be useful
834when referring to the Tk man pages.
835
836\begin{verbatim}
837Tk Tkinter Event Field Tk Tkinter Event Field
838-- ------------------- -- -------------------
839%f focus %A char
840%h height %E send_event
841%k keycode %K keysym
842%s state %N keysym_num
843%t time %T type
844%w width %W widget
845%x x %X x_root
846%y y %Y y_root
847\end{verbatim}
848
849
850\subsubsection{The index Parameter} % Index.html
851
852A number of widgets require``index'' parameters to be passed. These
853are used to point at a specific place in a Text widget, or to
854particular characters in an Entry widget, or to particular menu items
855in a Menu widget.
856
857\begin{description}
858\item[\b{Entry widget indexes (index, view index, etc.)}]
859Entry widgets have options that refer to character positions in the
860text being displayed. You can use these \refmodule{Tkinter} functions
861to access these special points in text widgets:
862\begin{description}
863\item[AtEnd()]
864refers to the last position in the text
865\item[AtInsert()]
866refers to the point where the text cursor is
867\item[AtSelFirst()]
868indicates the beginning point of the selected text
869\item[AtSelLast()]
870denotes the last point of the selected text and finally
871\item[At(x, y=None)]
872refers to the character at pixel location x, y (with y not used
873in the case of a text entry widget, which is one line of text).
874\end{description}
875
876\item[\b{Text widget indexes}]
877The index notation for Text widgets is very rich and is best described
878in the Tk man pages.
879
880\item[\b{Menu indexes (menu.invoke(), menu.entryconfig(), etc.)}]
881
882Some options and methods for menus manipulate specific menu entries.
883Anytime a menu index is needed for an option or a parameter, you may
884pass in:
885\begin{itemize}
886\item an integer which refers to the numeric position of the entry in
887the widget, counted from the top, starting with 0;
888\item the string \code{'active'}, which refers to the menu position that is
889currently under the cursor;
890\item the string \code{"last"} which refers to the last menu
891item;
892\item An integer preceded by \code{@}, as in \code{@6}, where the integer is
893interpreted as a y pixel coordinate in the menu's coordinate system;
894\item the string \code{"none"}, which indicates no menu entry at all, most
895often used with menu.activate() to deactivate all entries, and
896finally,
897\item a text string that is pattern matched against the label of the
898menu entry, as scanned from the top of the menu to the bottom. Note
899that this index type is considered after all the others, which means
900that matches for menu items labelled \code{last}, \code{active}, or
901\code{none} may be interpreted as the above literals, instead.
902\end{itemize}
903\end{description}
904
905
Fred Drakec66ff202001-11-16 01:05:27 +0000906\section{\module{Tix} ---
907 Extension widgets for Tk}
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000908
909\declaremodule{standard}{Tix}
910\modulesynopsis{Tk Extension Widgets for Tkinter}
911\sectionauthor{Mike Clarkson}{mikeclarkson@users.sourceforge.net}
912
Fred Drakec66ff202001-11-16 01:05:27 +0000913\index{Tix}
914
Fred Drake7cf4e5b2001-11-15 17:22:04 +0000915The \module{Tix} (Tk Interface Extension) module provides an
916additional rich set of widgets. Although the standard Tk library has
917many useful widgets, they are far from complete. The \module{Tix}
918library provides most of the commonly needed widgets that are missing
919from standard Tk: \class{HList}, \class{ComboBox}, \class{Control}
920(a.k.a. SpinBox) and an assortment of scrollable widgets. \module{Tix}
921also includes many more widgets that are generally useful in a wide
922range of applications: \class{NoteBook}, \class{FileEntry},
923\class{PanedWindow}, etc; there are more than 40 of them.
924
925With all these new widgets, you can introduce new interaction
926techniques into applications, creating more useful and more intuitive
927user interfaces. You can design your application by choosing the most
928appropriate widgets to match the special needs of your application and
929users.
930
931\begin{seealso}
932\seetitle[http://tix.sourceforge.net/]
933 {Tix Homepage}
934 {See the home page for \module{Tix}.}
935\seetitle[http://tix.sourceforge.net/dist/current/man/]
936 {Tix Man Pages}
937 {On-line version of the man pages and reference material.}
938\seetitle[http://tix.sourceforge.net/dist/current/docs/tix-book/tix.book.html]
939 {Tix Programming Guide}
940 {On-line version of the programmer's reference material.}
941\seetitle[http://tix.sourceforge.net/Tide/]
942 {Tix Development Applications}
943 {Tix applications for development of Tix and Tkinter programs.
944 Tide applications work under Tk or Tkinter, and include
945 \program{TixInspect}, an inspector to remotely modify and
946 debug Tix/Tk/Tkinter applications.}
947\end{seealso}
948
949
950\subsection{Using Tix}
951
952\begin{classdesc}{Tix}{screenName=None, baseName=None, className='Tix'}
953 Toplevel widget of Tix which represents mostly the main window
954 of an application. It has an associated Tcl interpreter.
955
956The \refmodule{Tix} interface module subclasses the \refmodule{Tkinter}
957module. The former imports the latter, so to use \refmodule{Tix} with
958Tkinter, all you need to do is to import one module. In general, you
959can just import Tix, and replace the toplevel call
960to \class{Tkinter.Tk} with \class{Tix.Tk}:
961\begin{verbatim}
962import Tix
963from Tkconstants import *
964root = Tix.Tk()
965\end{verbatim}
966\end{classdesc}
967
968To use \refmodule{Tix}, you must have the \refmodule{Tix} widgets installed,
969usually alongside your installation of the Tk widgets.
970To test your installation, try the following:
971\begin{verbatim}
972import Tix
973root = Tix.Tk()
974root.tk.eval('package require Tix')
975\end{verbatim}
976
977If this fails, you have a Tk installation problem which must be
978resolved before proceeding. Use the environment variable \envvar{TIX_LIBRARY}
979to point to the installed \refmodule{Tix} library directory, and
980make sure you have the dynamic object library (\file{tix8183.dll} or
981\file{libtix8183.so}) in the same directory that contains your Tk
982dynamic object library (\file{tk8183.dll} or \file{libtk8183.so}). The
983directory with the dynamic object library should also have a file
984called \file{pkgIndex.tcl} (case sensitive), which contains the line:
985
986\begin{verbatim}
987package ifneeded Tix 8.1 [list load "[file join $dir tix8183.dll]" Tix]
988\end{verbatim} % $ <-- bow to font-lock
989
990
991\subsection{Tix Widgets}
992
993\ulink{Tix}
994{http://tix.sourceforge.net/dist/current/man/html/TixCmd/TixIntro.htm}
995introduces over 40 widget classes to the \refmodule{Tkinter}
996repertoire. There is a demo of all the \refmodule{Tix} widgets in the
997\file{Demo/tix} directory of the standard distribution.
998
999
1000% The Python sample code is still being added to Python, hence commented out
1001
1002
1003\subsubsection{Basic Widgets}
1004
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001005\begin{classdesc}{Balloon}{}
1006A \ulink{Balloon}
Fred Drakec66ff202001-11-16 01:05:27 +00001007{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixBalloon.htm}
1008that pops up over a widget to provide help. When the user moves the
1009cursor inside a widget to which a Balloon widget has been bound, a
1010small pop-up window with a descriptive message will be shown on the
1011screen.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001012\end{classdesc}
1013
Fred Drakec66ff202001-11-16 01:05:27 +00001014% Python Demo of:
1015% \ulink{Balloon}{http://tix.sourceforge.net/dist/current/demos/samples/Balloon.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001016
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001017\begin{classdesc}{ButtonBox}{}
1018The \ulink{ButtonBox}
Fred Drakec66ff202001-11-16 01:05:27 +00001019{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixButtonBox.htm}
1020widget creates a box of buttons, such as is commonly used for \code{Ok
1021Cancel}.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001022\end{classdesc}
1023
Fred Drakec66ff202001-11-16 01:05:27 +00001024% Python Demo of:
1025% \ulink{ButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/BtnBox.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001026
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001027\begin{classdesc}{ComboBox}{}
1028The \ulink{ComboBox}
Fred Drakec66ff202001-11-16 01:05:27 +00001029{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixComboBox.htm}
1030widget is similar to the combo box control in MS Windows. The user can
1031select a choice by either typing in the entry subwdget or selecting
1032from the listbox subwidget.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001033\end{classdesc}
1034
Fred Drakec66ff202001-11-16 01:05:27 +00001035% Python Demo of:
1036% \ulink{ComboBox}{http://tix.sourceforge.net/dist/current/demos/samples/ComboBox.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001037
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001038\begin{classdesc}{Control}{}
1039The \ulink{Control}
Fred Drakec66ff202001-11-16 01:05:27 +00001040{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixControl.htm}
1041widget is also known as the \class{SpinBox} widget. The user can
1042adjust the value by pressing the two arrow buttons or by entering the
1043value directly into the entry. The new value will be checked against
1044the user-defined upper and lower limits.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001045\end{classdesc}
1046
Fred Drakec66ff202001-11-16 01:05:27 +00001047% Python Demo of:
1048% \ulink{Control}{http://tix.sourceforge.net/dist/current/demos/samples/Control.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001049
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001050\begin{classdesc}{LabelEntry}{}
1051The \ulink{LabelEntry}
Fred Drakec66ff202001-11-16 01:05:27 +00001052{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixLabelEntry.htm}
1053widget packages an entry widget and a label into one mega widget. It
1054can be used be used to simplify the creation of ``entry-form'' type of
1055interface.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001056\end{classdesc}
1057
1058% Python Demo of:
1059% \ulink{LabelEntry}{http://tix.sourceforge.net/dist/current/demos/samples/LabEntry.tcl}
1060
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001061\begin{classdesc}{LabelFrame}{}
1062The \ulink{LabelFrame}
Fred Drakec66ff202001-11-16 01:05:27 +00001063{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixLabelFrame.htm}
1064widget packages a frame widget and a label into one mega widget. To
1065create widgets inside a LabelFrame widget, one creates the new widgets
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001066relative to the \member{frame} subwidget and manage them inside the
1067\member{frame} subwidget.
1068\end{classdesc}
1069
1070% Python Demo of:
1071% \ulink{LabelFrame}{http://tix.sourceforge.net/dist/current/demos/samples/LabFrame.tcl}
1072
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001073\begin{classdesc}{Meter}{}
1074The \ulink{Meter}
Fred Drakec66ff202001-11-16 01:05:27 +00001075{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixMeter.htm}
1076widget can be used to show the progress of a background job which may
1077take a long time to execute.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001078\end{classdesc}
1079
1080% Python Demo of:
1081% \ulink{Meter}{http://tix.sourceforge.net/dist/current/demos/samples/Meter.tcl}
1082
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001083\begin{classdesc}{OptionMenu}{}
1084The \ulink{OptionMenu}
Fred Drakec66ff202001-11-16 01:05:27 +00001085{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixOptionMenu.htm}
1086creates a menu button of options.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001087\end{classdesc}
1088
Fred Drakec66ff202001-11-16 01:05:27 +00001089% Python Demo of:
1090% \ulink{OptionMenu}{http://tix.sourceforge.net/dist/current/demos/samples/OptMenu.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001091
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001092\begin{classdesc}{PopupMenu}{}
1093The \ulink{PopupMenu}
Fred Drakec66ff202001-11-16 01:05:27 +00001094{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixPopupMenu.htm}
1095widget can be used as a replacement of the \code{tk_popup}
1096command. The advantage of the \refmodule{Tix} \class{PopupMenu} widget
1097is it requires less application code to manipulate.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001098\end{classdesc}
1099
Fred Drakec66ff202001-11-16 01:05:27 +00001100% Python Demo of:
1101% \ulink{PopupMenu}{http://tix.sourceforge.net/dist/current/demos/samples/PopMenu.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001102
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001103\begin{classdesc}{Select}{}
1104The \ulink{Select}
Fred Drakec66ff202001-11-16 01:05:27 +00001105{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixSelect.htm}
1106widget is a container of button subwidgets. It can be used to provide
1107radio-box or check-box style of selection options for the user.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001108\end{classdesc}
1109
Fred Drakec66ff202001-11-16 01:05:27 +00001110% Python Demo of:
1111% \ulink{Select}{http://tix.sourceforge.net/dist/current/demos/samples/Select.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001112
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001113\begin{classdesc}{StdButtonBox}{}
1114The \ulink{StdButtonBox}
Fred Drakec66ff202001-11-16 01:05:27 +00001115{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixStdButtonBox.htm}
1116widget is a group of standard buttons for Motif-like dialog boxes.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001117\end{classdesc}
1118
Fred Drakec66ff202001-11-16 01:05:27 +00001119% Python Demo of:
1120% \ulink{StdButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/StdBBox.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001121
1122
1123\subsubsection{File Selectors}
1124
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001125\begin{classdesc}{DirList}{}
1126The \ulink{DirList}
1127{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixDirList.htm} widget
1128displays a list view of a directory, its previous directories and its
1129sub-directories. The user can choose one of the directories displayed
1130in the list or change to another directory.
1131\end{classdesc}
1132
Fred Drakec66ff202001-11-16 01:05:27 +00001133% Python Demo of:
1134% \ulink{DirList}{http://tix.sourceforge.net/dist/current/demos/samples/DirList.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001135
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001136\begin{classdesc}{DirTree}{}
1137The \ulink{DirTree}
Fred Drakec66ff202001-11-16 01:05:27 +00001138{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixDirTree.htm}
1139widget displays a tree view of a directory, its previous directories
1140and its sub-directories. The user can choose one of the directories
1141displayed in the list or change to another directory.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001142\end{classdesc}
1143
Fred Drakec66ff202001-11-16 01:05:27 +00001144% Python Demo of:
1145% \ulink{DirTree}{http://tix.sourceforge.net/dist/current/demos/samples/DirTree.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001146
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001147\begin{classdesc}{DirSelectDialog}{}
1148The \ulink{DirSelectDialog}
Fred Drakec66ff202001-11-16 01:05:27 +00001149{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixDirSelectDialog.htm}
1150widget presents the directories in the file system in a dialog
1151window. The user can use this dialog window to navigate through the
1152file system to select the desired directory.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001153\end{classdesc}
1154
Fred Drakec66ff202001-11-16 01:05:27 +00001155% Python Demo of:
1156% \ulink{DirSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/DirDlg.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001157
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001158\begin{classdesc}{DirSelectBox}{}
1159The \class{DirSelectBox} is similar
1160to the standard Motif(TM) directory-selection box. It is generally used for
1161the user to choose a directory. DirSelectBox stores the directories mostly
1162recently selected into a ComboBox widget so that they can be quickly
1163selected again.
1164\end{classdesc}
1165
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001166\begin{classdesc}{ExFileSelectBox}{}
1167The \ulink{ExFileSelectBox}
Fred Drakec66ff202001-11-16 01:05:27 +00001168{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixExFileSelectBox.htm}
1169widget is usually embedded in a tixExFileSelectDialog widget. It
1170provides an convenient method for the user to select files. The style
1171of the \class{ExFileSelectBox} widget is very similar to the standard
1172file dialog on MS Windows 3.1.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001173\end{classdesc}
1174
Fred Drakec66ff202001-11-16 01:05:27 +00001175% Python Demo of:
1176%\ulink{ExFileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/EFileDlg.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001177
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001178\begin{classdesc}{FileSelectBox}{}
1179The \ulink{FileSelectBox}
Fred Drakec66ff202001-11-16 01:05:27 +00001180{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixFileSelectBox.htm}
1181is similar to the standard Motif(TM) file-selection box. It is
1182generally used for the user to choose a file. FileSelectBox stores the
1183files mostly recently selected into a \class{ComboBox} widget so that
1184they can be quickly selected again.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001185\end{classdesc}
1186
Fred Drakec66ff202001-11-16 01:05:27 +00001187% Python Demo of:
1188% \ulink{FileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/FileDlg.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001189
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001190\begin{classdesc}{FileEntry}{}
1191The \ulink{FileEntry}
Fred Drakec66ff202001-11-16 01:05:27 +00001192{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixFileEntry.htm}
1193widget can be used to input a filename. The user can type in the
1194filename manually. Alternatively, the user can press the button widget
1195that sits next to the entry, which will bring up a file selection
1196dialog.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001197\end{classdesc}
1198
Fred Drakec66ff202001-11-16 01:05:27 +00001199% Python Demo of:
1200% \ulink{FileEntry}{http://tix.sourceforge.net/dist/current/demos/samples/FileEnt.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001201
1202
1203\subsubsection{Hierachical ListBox}
1204
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001205\begin{classdesc}{HList}{}
1206The \ulink{HList}
Fred Drakec66ff202001-11-16 01:05:27 +00001207{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixHList.htm}
1208widget can be used to display any data that have a hierarchical
1209structure, for example, file system directory trees. The list entries
1210are indented and connected by branch lines according to their places
1211in the hierachy.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001212\end{classdesc}
1213
Fred Drakec66ff202001-11-16 01:05:27 +00001214% Python Demo of:
1215% \ulink{HList}{http://tix.sourceforge.net/dist/current/demos/samples/HList1.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001216
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001217\begin{classdesc}{CheckList}{}
1218The \ulink{CheckList}
Fred Drakec66ff202001-11-16 01:05:27 +00001219{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixCheckList.htm}
1220widget displays a list of items to be selected by the user. CheckList
1221acts similarly to the Tk checkbutton or radiobutton widgets, except it
1222is capable of handling many more items than checkbuttons or
1223radiobuttons.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001224\end{classdesc}
1225
Fred Drakec66ff202001-11-16 01:05:27 +00001226% Python Demo of:
1227% \ulink{ CheckList}{http://tix.sourceforge.net/dist/current/demos/samples/ChkList.tcl}
1228% Python Demo of:
1229% \ulink{ScrolledHList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList.tcl}
1230% Python Demo of:
1231% \ulink{ScrolledHList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList2.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001232
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001233\begin{classdesc}{Tree}{}
1234The \ulink{Tree}
Fred Drakec66ff202001-11-16 01:05:27 +00001235{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixTree.htm}
1236widget can be used to display hierachical data in a tree form. The
1237user can adjust the view of the tree by opening or closing parts of
1238the tree.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001239\end{classdesc}
1240
Fred Drakec66ff202001-11-16 01:05:27 +00001241% Python Demo of:
1242% \ulink{Tree}{http://tix.sourceforge.net/dist/current/demos/samples/Tree.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001243
Fred Drakec66ff202001-11-16 01:05:27 +00001244% Python Demo of:
1245% \ulink{Tree (Dynamic)}{http://tix.sourceforge.net/dist/current/demos/samples/DynTree.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001246
1247
1248\subsubsection{Tabular ListBox}
1249
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001250\begin{classdesc}{TList}{}
1251The \ulink{TList}
Fred Drakec66ff202001-11-16 01:05:27 +00001252{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixTList.htm}
1253widget can be used to display data in a tabular format. The list
1254entries of a \class{TList} widget are similar to the entries in the Tk
1255listbox widget. The main differences are (1) the \class{TList} widget
1256can display the list entries in a two dimensional format and (2) you
1257can use graphical images as well as multiple colors and fonts for the
1258list entries.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001259\end{classdesc}
1260
Fred Drakec66ff202001-11-16 01:05:27 +00001261% Python Demo of:
1262% \ulink{ScrolledTList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/STList1.tcl}
1263% Python Demo of:
1264% \ulink{ScrolledTList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/STList2.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001265
1266% Grid has yet to be added to Python
1267% \subsubsection{Grid Widget}
Fred Drakec66ff202001-11-16 01:05:27 +00001268% Python Demo of:
1269% \ulink{Simple Grid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid0.tcl}
1270% Python Demo of:
1271% \ulink{ScrolledGrid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid1.tcl}
1272% Python Demo of:
1273% \ulink{Editable Grid}{http://tix.sourceforge.net/dist/current/demos/samples/EditGrid.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001274
1275
1276\subsubsection{Manager Widgets}
1277
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001278\begin{classdesc}{PanedWindow}{}
1279The \ulink{PanedWindow}
Fred Drakec66ff202001-11-16 01:05:27 +00001280{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixPanedWindow.htm}
1281widget allows the user to interactively manipulate the sizes of
1282several panes. The panes can be arranged either vertically or
1283horizontally. The user changes the sizes of the panes by dragging the
1284resize handle between two panes.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001285\end{classdesc}
1286
Fred Drakec66ff202001-11-16 01:05:27 +00001287% Python Demo of:
1288% \ulink{PanedWindow}{http://tix.sourceforge.net/dist/current/demos/samples/PanedWin.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001289
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001290\begin{classdesc}{ListNoteBook}{}
1291The \ulink{ListNoteBook}
Fred Drakec66ff202001-11-16 01:05:27 +00001292{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixListNoteBook.htm}
1293widget is very similar to the \class{TixNoteBook} widget: it can be
1294used to display many windows in a limited space using a notebook
1295metaphor. The notebook is divided into a stack of pages (windows). At
1296one time only one of these pages can be shown. The user can navigate
1297through these pages by choosing the name of the desired page in the
1298\member{hlist} subwidget.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001299\end{classdesc}
1300
Fred Drakec66ff202001-11-16 01:05:27 +00001301% Python Demo of:
1302% \ulink{ListNoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/ListNBK.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001303
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001304\begin{classdesc}{NoteBook}{}
1305The \ulink{NoteBook}
Fred Drakec66ff202001-11-16 01:05:27 +00001306{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm}
1307widget can be used to display many windows in a limited space using a
1308notebook metaphor. The notebook is divided into a stack of pages. At
1309one time only one of these pages can be shown. The user can navigate
1310through these pages by choosing the visual ``tabs'' at the top of the
1311NoteBook widget.
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001312\end{classdesc}
1313
Fred Drakec66ff202001-11-16 01:05:27 +00001314% Python Demo of:
1315% \ulink{NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/NoteBook.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001316
1317
1318% \subsubsection{Scrolled Widgets}
Fred Drakec66ff202001-11-16 01:05:27 +00001319% Python Demo of:
1320% \ulink{ScrolledListBox}{http://tix.sourceforge.net/dist/current/demos/samples/SListBox.tcl}
1321% Python Demo of:
1322% \ulink{ScrolledText}{http://tix.sourceforge.net/dist/current/demos/samples/SText.tcl}
1323% Python Demo of:
1324% \ulink{ScrolledWindow}{http://tix.sourceforge.net/dist/current/demos/samples/SWindow.tcl}
1325% Python Demo of:
1326% \ulink{Canvas Object View}{http://tix.sourceforge.net/dist/current/demos/samples/CObjView.tcl}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001327
1328
1329\subsubsection{Image Types}
1330
1331The \refmodule{Tix} module adds:
1332\begin{itemize}
1333\item
1334\ulink{pixmap}
1335{http://tix.sourceforge.net/dist/current/man/html/TixCmd/pixmap.htm} capabilities
1336to all \refmodule{Tix} and \refmodule{Tkinter} widgets to create color
1337images from XPM files.
1338
1339% Python Demo of: \ulink{XPM Image In Button}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm.tcl}
1340
1341% Python Demo of: \ulink{XPM Image In Menu}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm1.tcl}
1342
1343\item
1344\ulink{Compound}
1345{http://tix.sourceforge.net/dist/current/man/html/TixCmd/compound.html} image
1346types can be used to create images that consists of multiple
1347horizontal lines; each line is composed of a series of items (texts,
1348bitmaps, images or spaces) arranged from left to right. For example, a
1349compound image can be used to display a bitmap and a text string
1350simutaneously in a Tk \class{Button} widget.
1351
1352% Python Demo of: \ulink{Compound Image In Buttons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg.tcl}
1353
1354% Python Demo of: \ulink{Compound Image In NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg2.tcl}
1355
1356% Python Demo of: \ulink{Compound Image Notebook Color Tabs}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg4.tcl}
1357
1358% Python Demo of: \ulink{Compound Image Icons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg3.tcl}
1359\end{itemize}
1360
1361
1362\subsubsection{Miscellaneous Widgets}
1363
1364\index{InputOnly widget}
1365\begin{classdesc}{InputOnly}{}
1366The \ulink{InputOnly}
1367{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixInputOnly.htm} widgets are
1368to accept inputs from the user, which can be done with the \code{bind}
1369command (\UNIX{} only).
1370\end{classdesc}
1371
1372\subsubsection{Form Geometry Manager}
1373
1374In addition, \refmodule{Tix} augments \refmodule{Tkinter} by providing:
1375\index{Form widget class}
1376\begin{classdesc}{Form}{}
1377The \ulink{Form}
1378{http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixForm.htm} geometry
1379manager based on attachment rules for all Tk widgets.
1380\end{classdesc}
1381
1382
1383%begin{latexonly}
1384%\subsection{Tix Class Structure}
1385%
1386%\begin{figure}[hbtp]
1387%\centerline{\epsfig{file=hierarchy.png,width=.9\textwidth}}
1388%\vspace{.5cm}
1389%\caption{The Class Hierarchy of Tix Widgets}
1390%\end{figure}
1391%end{latexonly}
1392
1393
Fred Drakec66ff202001-11-16 01:05:27 +00001394\input{libturtle}
Fred Drake7cf4e5b2001-11-15 17:22:04 +00001395
1396
1397\section{Idle \label{idle}}
1398
1399%\declaremodule{standard}{idle}
1400%\modulesynopsis{A Python Integrated Developement Environment}
1401\moduleauthor{Guido van Rossum}{guido@Python.org}
1402
1403Idle is the Python IDE built with the \refmodule{Tkinter} GUI toolkit.
1404\index{Idle}
1405\index{Python Editor}
1406\index{Integrated Developement Environment}
1407
1408
1409IDLE has the following features:
1410
1411\begin{itemize}
1412\item coded in 100\% pure Python, using the \refmodule{Tkinter} GUI toolkit
1413
1414\item cross-platform: works on Windows and \UNIX{} (on Mac OS, there are
1415currently problems with Tcl/Tk)
1416
1417\item multi-window text editor with multiple undo, Python colorizing
1418and many other features, e.g. smart indent and call tips
1419
1420\item Python shell window (a.k.a. interactive interpreter)
1421
1422\item debugger (not complete, but you can set breakpoints, view and step)
1423\end{itemize}
1424
1425
1426\subsection{Menus}
1427
1428\subsubsection{File menu}
1429
1430\begin{description}
1431\item[New window] create a new editing window
1432\item[Open...] open an existing file
1433\item[Open module...] open an existing module (searches sys.path)
1434\item[Class browser] show classes and methods in current file
1435\item[Path browser] show sys.path directories, modules, classes and methods
1436\end{description}
1437\index{Class browser}
1438\index{Path browser}
1439
1440\begin{description}
1441\item[Save] save current window to the associated file (unsaved
1442windows have a * before and after the window title)
1443
1444\item[Save As...] save current window to new file, which becomes
1445the associated file
1446\item[Save Copy As...] save current window to different file
1447without changing the associated file
1448\end{description}
1449
1450\begin{description}
1451\item[Close] close current window (asks to save if unsaved)
1452\item[Exit] close all windows and quit IDLE (asks to save if unsaved)
1453\end{description}
1454
1455
1456\subsubsection{Edit menu}
1457
1458\begin{description}
1459\item[Undo] Undo last change to current window (max 1000 changes)
1460\item[Redo] Redo last undone change to current window
1461\end{description}
1462
1463\begin{description}
1464\item[Cut] Copy selection into system-wide clipboard; then delete selection
1465\item[Copy] Copy selection into system-wide clipboard
1466\item[Paste] Insert system-wide clipboard into window
1467\item[Select All] Select the entire contents of the edit buffer
1468\end{description}
1469
1470\begin{description}
1471\item[Find...] Open a search dialog box with many options
1472\item[Find again] Repeat last search
1473\item[Find selection] Search for the string in the selection
1474\item[Find in Files...] Open a search dialog box for searching files
1475\item[Replace...] Open a search-and-replace dialog box
1476\item[Go to line] Ask for a line number and show that line
1477\end{description}
1478
1479\begin{description}
1480\item[Indent region] Shift selected lines right 4 spaces
1481\item[Dedent region] Shift selected lines left 4 spaces
1482\item[Comment out region] Insert \#\# in front of selected lines
1483\item[Uncomment region] Remove leading \# or \#\# from selected lines
1484\item[Tabify region] Turns \emph{leading} stretches of spaces into tabs
1485\item[Untabify region] Turn \emph{all} tabs into the right number of spaces
1486\item[Expand word] Expand the word you have typed to match another
1487 word in the same buffer; repeat to get a different expansion
1488\item[Format Paragraph] Reformat the current blank-line-separated paragraph
1489\end{description}
1490
1491\begin{description}
1492\item[Import module] Import or reload the current module
1493\item[Run script] Execute the current file in the __main__ namespace
1494\end{description}
1495
1496\index{Import module}
1497\index{Run script}
1498
1499
1500\subsubsection{Windows menu}
1501
1502\begin{description}
1503\item[Zoom Height] toggles the window between normal size (24x80)
1504 and maximum height.
1505\end{description}
1506
1507The rest of this menu lists the names of all open windows; select one
1508to bring it to the foreground (deiconifying it if necessary).
1509
1510
1511\subsubsection{Debug menu (in the Python Shell window only)}
1512
1513\begin{description}
1514\item[Go to file/line] look around the insert point for a filename
1515 and linenumber, open the file, and show the line.
1516\item[Open stack viewer] show the stack traceback of the last exception
1517\item[Debugger toggle] Run commands in the shell under the debugger
1518\item[JIT Stack viewer toggle] Open stack viewer on traceback
1519\end{description}
1520
1521\index{stack viewer}
1522\index{debugger}
1523
1524
1525\subsection{Basic editing and navigation}
1526
1527\begin{itemize}
1528\item \kbd{Backspace} deletes to the left; \kbd{Del} deletes to the right
1529\item Arrow keys and \kbd{Page Up}/\kbd{Page Down} to move around
1530\item \kbd{Home}/\kbd{End} go to begin/end of line
1531\item \kbd{C-Home}/\kbd{C-End} go to begin/end of file
1532\item Some \program{Emacs} bindings may also work, including \kbd{C-B},
1533 \kbd{C-P}, \kbd{C-A}, \kbd{C-E}, \kbd{C-D}, \kbd{C-L}
1534\end{itemize}
1535
1536
1537\subsubsection{Automatic indentation}
1538
1539After a block-opening statement, the next line is indented by 4 spaces
1540(in the Python Shell window by one tab). After certain keywords
1541(break, return etc.) the next line is dedented. In leading
1542indentation, \kbd{Backspace} deletes up to 4 spaces if they are there.
1543\kbd{Tab} inserts 1-4 spaces (in the Python Shell window one tab).
1544See also the indent/dedent region commands in the edit menu.
1545
1546
1547\subsubsection{Python Shell window}
1548
1549\begin{itemize}
1550\item \kbd{C-C} interrupts executing command
1551\item \kbd{C-D} sends end-of-file; closes window if typed at
1552a \samp{>>>~} prompt
1553\end{itemize}
1554
1555\begin{itemize}
1556\item Alt-p retrieves previous command matching what you have typed
1557\item Alt-n retrieves next
1558\item \kbd{Return} while on any previous command retrieves that command
1559\item Alt-/ (Expand word) is also useful here
1560\end{itemize}
1561
1562\index{indentation}
1563
1564
1565\subsection{Syntax colors}
1566
1567The coloring is applied in a background ``thread,'' so you may
1568occasionally see uncolorized text. To change the color
1569scheme, edit the \code{[Colors]} section in \file{config.txt}.
1570
1571\begin{description}
1572\item[Python syntax colors:]
1573
1574\begin{description}
1575\item[Keywords] orange
1576\item[Strings ] green
1577\item[Comments] red
1578\item[Definitions] blue
1579\end{description}
1580
1581\item[Shell colors:]
1582\begin{description}
1583\item[Console output] brown
1584\item[stdout] blue
1585\item[stderr] dark green
1586\item[stdin] black
1587\end{description}
1588\end{description}
1589
1590
1591\subsubsection{Command line usage}
1592
1593\begin{verbatim}
1594idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
1595
1596-c command run this command
1597-d enable debugger
1598-e edit mode; arguments are files to be edited
1599-s run $IDLESTARTUP or $PYTHONSTARTUP first
1600-t title set title of shell window
1601\end{verbatim}
1602
1603If there are arguments:
1604
1605\begin{enumerate}
1606\item If \programopt{-e} is used, arguments are files opened for
1607 editing and \code{sys.argv} reflects the arguments passed to
1608 IDLE itself.
1609
1610\item Otherwise, if \programopt{-c} is used, all arguments are
1611 placed in \code{sys.argv[1:...]}, with \code{sys.argv[0]} set
1612 to \code{'-c'}.
1613
1614\item Otherwise, if neither \programopt{-e} nor \programopt{-c} is
1615 used, the first argument is a script which is executed with
1616 the remaining arguments in \code{sys.argv[1:...]} and
1617 \code{sys.argv[0]} set to the script name. If the script name
1618 is '-', no script is executed but an interactive Python
1619 session is started; the arguments are still available in
1620 \code{sys.argv}.
1621\end{enumerate}
Fred Drakec66ff202001-11-16 01:05:27 +00001622
1623
1624\section{Other Graphical User Interface Packages
1625 \label{other-gui-packages}}
1626
1627
1628There are an number of extension widget sets to \refmodule{Tkinter}.
1629
1630\begin{seealso}
1631\seetitle[http://pmw.sourceforge.net/]{Python megawidgets}{is a
1632toolkit for building high-level compound widgets in Python using the
1633\refmodule{Tkinter} module. It consists of a set of base classes and
1634a library of flexible and extensible megawidgets built on this
1635foundation. These megawidgets include notebooks, comboboxes, selection
1636widgets, paned widgets, scrolled widgets, dialog windows, etc. Also,
1637with the Pmw.Blt interface to BLT, the busy, graph, stripchart, tabset
1638and vector commands are be available.
1639
1640The initial ideas for Pmw were taken from the Tk \code{itcl}
1641extensions \code{[incr Tk]} by Michael McLennan and \code{[incr
1642Widgets]} by Mark Ulferts. Several of the megawidgets are direct
1643translations from the itcl to Python. It offers most of the range of
1644widgets that \code{[incr Widgets]} does, and is almost as complete as
1645Tix, lacking however Tix's fast \class{HList} widget for drawing trees.
1646}
1647\seetitle[http://tkinter.effbot.org]{Tkinter3000}{
1648is a Widget Construction Kit that allows you to write new Tkinter
1649widgets in Python using Mixins. It is built on top of Tkinter,
1650and does not offer the extended range of widgets that \refmodule{Tix} does,
1651but does allow a form of building mega-widgets. The project is
1652still in the early stages.
1653}
1654\end{seealso}
1655
1656
1657\refmodule{Tkinter} is not the only GUI for Python, but is however the
1658most commonly used one.
1659
1660\begin{seealso}
1661\seetitle[http://www.wxwindows.org]{wxWindows}{
1662is a GUI toolkit that combines the most attractive attributes of Qt,
1663Tk, Motif, and GTK+ in one powerful and efficient package. It is
1664implemented in \Cpp. wxWindows supports two flavors of Unix
1665implementation: GTK+ and Motif, and under Windows, it has a standard
1666Microsoft Foundation Classes (MFC) appearance, because it uses Win32
1667widgets. There is a Python class wrapper, independent of Tkinter.
1668
1669wxWindows is much richer in widgets than \refmodule{Tkinter}, with its
1670help system, sophisticated HTML and image viewers, and other
1671specialized widgets, extensive documentation, and printing capabilities.
1672}
1673\seetitle[http://www.thekompany.com]{PyKDE}{
1674PyKDE is a SIP wrapped interface to the Qt toolkit.
1675The Qt \Cpp{} toolkit lies at the heart of the KDE desktop, and the
1676Qt toolkit allows very tight integration with KDE, and also Windows
1677portability. SIP is a tool for generating bindings for \Cpp{} libraries
1678as Python classes, and is specifically designed for Python.
1679}
1680\seetitle[http://fxpy.sourceforge.net/]{FXPy}{
1681is a Python extension module which provides an interface to the
1682\citetitle[http://www.cfdrc.com/FOX/fox.html]{FOX} GUI.
1683FOX is a \Cpp{} based Toolkit for developing Graphical User Interfaces
1684easily and effectively. It offers a wide, and growing, collection of
1685Controls, and provides state of the art facilities such as drag and
1686drop, selection, as well as OpenGL widgets for 3D graphical
1687manipulation. FOX also implements icons, images, and user-convenience
1688features such as status line help, and tooltips.
1689
1690Even though FOX offers a large collection of controls already, FOX
1691leverages \Cpp{} to allow programmers to easily build additional Controls
1692and GUI elements, simply by taking existing controls, and creating a
1693derived class which simply adds or redefines the desired behavior.
1694}
1695\seetitle[http://www.daa.com.au/\~james/pygtk/]{PyGTK}{
1696is a set of bindings for the \ulink{GTK}{http://www.gtk.org/} widget set.
1697It provides an object oriented interface that is slightly higher
1698level than the C one. It automatically does all the type casting and
1699reference counting that you would have to do normally with the C
1700API. There are also \ulink{bindings}{http://www.daa.com.au/\~james/gnome/}
1701to \ulink{GNOME}{http://www.gnome.org}, and a
1702\ulink{tutorial}
1703{http://laguna.fmedic.unam.mx/\~daniel/pygtutorial/pygtutorial/index.html}
1704is available.
1705}
1706\end{seealso}
1707
1708% XXX Reference URLs that compare the different UI packages