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