| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="node716.html" /> |
| 13 | <link rel="prev" href="module-Tkinter.html" /> |
| 14 | <link rel="parent" href="module-Tkinter.html" /> |
| 15 | <link rel="next" href="node716.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>16.1.1 Tkinter Modules</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="16.1 Tkinter " |
| 25 | href="module-Tkinter.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="16.1 Tkinter " |
| 28 | href="module-Tkinter.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="16.1.2 Tkinter Life Preserver" |
| 31 | href="node716.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-Tkinter.html">16.1 Tkinter </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="module-Tkinter.html">16.1 Tkinter </A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="node716.html">16.1.2 Tkinter Life Preserver</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H2><A NAME="SECTION0018110000000000000000"> |
| 56 | 16.1.1 Tkinter Modules</A> |
| 57 | </H2> |
| 58 | |
| 59 | <P> |
| 60 | Most of the time, the <tt class="module"><a href="module-Tkinter.html">Tkinter</a></tt> module is all you really |
| 61 | need, but a number of additional modules are available as well. The |
| 62 | Tk interface is located in a binary module named <tt class="module">_tkinter</tt>. |
| 63 | This module contains the low-level interface to Tk, and should never |
| 64 | be used directly by application programmers. It is usually a shared |
| 65 | library (or DLL), but might in some cases be statically linked with |
| 66 | the Python interpreter. |
| 67 | |
| 68 | <P> |
| 69 | In addition to the Tk interface module, <tt class="module"><a href="module-Tkinter.html">Tkinter</a></tt> includes a |
| 70 | number of Python modules. The two most important modules are the |
| 71 | <tt class="module"><a href="module-Tkinter.html">Tkinter</a></tt> module itself, and a module called |
| 72 | <tt class="module">Tkconstants</tt>. The former automatically imports the latter, so |
| 73 | to use Tkinter, all you need to do is to import one module: |
| 74 | |
| 75 | <P> |
| 76 | <div class="verbatim"><pre> |
| 77 | import Tkinter |
| 78 | </pre></div> |
| 79 | |
| 80 | <P> |
| 81 | Or, more often: |
| 82 | |
| 83 | <P> |
| 84 | <div class="verbatim"><pre> |
| 85 | from Tkinter import * |
| 86 | </pre></div> |
| 87 | |
| 88 | <P> |
| 89 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 90 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-4835' xml:id='l2h-4835' class="class">Tk</tt></b>(</nobr></td> |
| 91 | <td><var>screenName=None, baseName=None, className='Tk', useTk=1</var>)</td></tr></table></dt> |
| 92 | <dd> |
| 93 | The <tt class="class">Tk</tt> class is instantiated without arguments. |
| 94 | This creates a toplevel widget of Tk which usually is the main window |
| 95 | of an application. Each instance has its own associated Tcl interpreter. |
| 96 | |
| 97 | <span class="versionnote">Changed in version 2.4: |
| 98 | The <var>useTk</var> parameter was added.</span> |
| 99 | |
| 100 | </dl> |
| 101 | |
| 102 | <P> |
| 103 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 104 | <td><nobr><b><tt id='l2h-4836' xml:id='l2h-4836' class="function">Tcl</tt></b>(</nobr></td> |
| 105 | <td><var>screenName=None, baseName=None, className='Tk', useTk=0</var>)</td></tr></table></dt> |
| 106 | <dd> |
| 107 | The <tt class="function">Tcl</tt> function is a factory function which creates an object |
| 108 | much like that created by the <tt class="class">Tk</tt> class, except that it does not |
| 109 | initialize the Tk subsystem. This is most often useful when driving the Tcl |
| 110 | interpreter in an environment where one doesn't want to create extraneous |
| 111 | toplevel windows, or where one cannot (i.e. Unix/Linux systems without an X |
| 112 | server). An object created by the <tt class="function">Tcl</tt> object can have a Toplevel |
| 113 | window created (and the Tk subsystem initialized) by calling its |
| 114 | <tt class="method">loadtk</tt> method. |
| 115 | |
| 116 | <span class="versionnote">New in version 2.4.</span> |
| 117 | |
| 118 | </dl> |
| 119 | |
| 120 | <P> |
| 121 | Other modules that provide Tk support include: |
| 122 | |
| 123 | <P> |
| 124 | <DL> |
| 125 | <DT><STRONG><tt class="module"><a href="module-ScrolledText.html">ScrolledText</a></tt></STRONG></DT> |
| 126 | <DD>Text widget with a vertical scroll bar built in. |
| 127 | |
| 128 | <P> |
| 129 | </DD> |
| 130 | <DT><STRONG><tt class="module">tkColorChooser</tt></STRONG></DT> |
| 131 | <DD>Dialog to let the user choose a color. |
| 132 | |
| 133 | <P> |
| 134 | </DD> |
| 135 | <DT><STRONG><tt class="module">tkCommonDialog</tt></STRONG></DT> |
| 136 | <DD>Base class for the dialogs defined in the other modules listed here. |
| 137 | |
| 138 | <P> |
| 139 | </DD> |
| 140 | <DT><STRONG><tt class="module">tkFileDialog</tt></STRONG></DT> |
| 141 | <DD>Common dialogs to allow the user to specify a file to open or save. |
| 142 | |
| 143 | <P> |
| 144 | </DD> |
| 145 | <DT><STRONG><tt class="module">tkFont</tt></STRONG></DT> |
| 146 | <DD>Utilities to help work with fonts. |
| 147 | |
| 148 | <P> |
| 149 | </DD> |
| 150 | <DT><STRONG><tt class="module">tkMessageBox</tt></STRONG></DT> |
| 151 | <DD>Access to standard Tk dialog boxes. |
| 152 | |
| 153 | <P> |
| 154 | </DD> |
| 155 | <DT><STRONG><tt class="module">tkSimpleDialog</tt></STRONG></DT> |
| 156 | <DD>Basic dialogs and convenience functions. |
| 157 | |
| 158 | <P> |
| 159 | </DD> |
| 160 | <DT><STRONG><tt class="module">Tkdnd</tt></STRONG></DT> |
| 161 | <DD>Drag-and-drop support for <tt class="module"><a href="module-Tkinter.html">Tkinter</a></tt>. |
| 162 | This is experimental and should become deprecated when it is replaced |
| 163 | with the Tk DND. |
| 164 | |
| 165 | <P> |
| 166 | </DD> |
| 167 | <DT><STRONG><tt class="module"><a href="module-turtle.html">turtle</a></tt></STRONG></DT> |
| 168 | <DD>Turtle graphics in a Tk window. |
| 169 | |
| 170 | <P> |
| 171 | </DD> |
| 172 | </DL> |
| 173 | |
| 174 | <P> |
| 175 | |
| 176 | <DIV CLASS="navigation"> |
| 177 | <div class='online-navigation'> |
| 178 | <p></p><hr /> |
| 179 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 180 | <tr> |
| 181 | <td class='online-navigation'><a rel="prev" title="16.1 Tkinter " |
| 182 | href="module-Tkinter.html"><img src='../icons/previous.png' |
| 183 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 184 | <td class='online-navigation'><a rel="parent" title="16.1 Tkinter " |
| 185 | href="module-Tkinter.html"><img src='../icons/up.png' |
| 186 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 187 | <td class='online-navigation'><a rel="next" title="16.1.2 Tkinter Life Preserver" |
| 188 | href="node716.html"><img src='../icons/next.png' |
| 189 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 190 | <td align="center" width="100%">Python Library Reference</td> |
| 191 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 192 | href="contents.html"><img src='../icons/contents.png' |
| 193 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 194 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 195 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 196 | <td class='online-navigation'><a rel="index" title="Index" |
| 197 | href="genindex.html"><img src='../icons/index.png' |
| 198 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 199 | </tr></table> |
| 200 | <div class='online-navigation'> |
| 201 | <b class="navlabel">Previous:</b> |
| 202 | <a class="sectref" rel="prev" href="module-Tkinter.html">16.1 Tkinter </A> |
| 203 | <b class="navlabel">Up:</b> |
| 204 | <a class="sectref" rel="parent" href="module-Tkinter.html">16.1 Tkinter </A> |
| 205 | <b class="navlabel">Next:</b> |
| 206 | <a class="sectref" rel="next" href="node716.html">16.1.2 Tkinter Life Preserver</A> |
| 207 | </div> |
| 208 | </div> |
| 209 | <hr /> |
| 210 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 211 | </DIV> |
| 212 | <!--End of Navigation Panel--> |
| 213 | <ADDRESS> |
| 214 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 215 | </ADDRESS> |
| 216 | </BODY> |
| 217 | </HTML> |